I'm new in sandbox and i'm developping an event receiver itemupdated and i need an alternative of runwithelevatedprivileges. I need it for using

item.file.moveTo("new libraray url");

I need it because user that move the item shouldn't have permission enough

The user can move file choosing a value in a select list but he can't go to the library where the item is mooved

Thanks for your help


RWEP is not available in the sandbox. Your alternative would be to grant a custom permission to the location where you are moving files to that grants the user Add Items or create a full trust proxy. For permissions, in your event receiver, you move the file normally. Users cannot modify items, users cannot delete items, only add new files. Fills the gap easily.

There is a MSDN article on full trust proxies for sandbox solutions that might help, http://msdn.microsoft.com/en-us/library/ff798482.aspx, but to me, this seems like overkill when a simple permission change can do the same thing.

  • Thanks a lot for your explanation. I'm not sure that i understand everything. I should add a permission for the user that move file? Do you have a sample of code to perform this solution? – user1898765 Jul 1 '14 at 21:06
  • 1
    What I mean is, in the document library where you want to move this file, you give all users a custom permission level to add items. When your event receiver triggers, it would be running as the current user, and you can move the file without needing to elevate permissions. Users can only add items to this library, so there is no malicious things to worry about, like deleting files created by other users. – Eric Alexander Jul 1 '14 at 21:22
  • thanks for your solution i'm gonna test this. but didn't need delete permission in the folder if we make a moveTo? – user1898765 Jul 2 '14 at 6:28

Instead of an event receiver, can you utilize the Content Organizer feature instead? http://msdn.microsoft.com/en-us/library/office/ee558288%28v=office.14%29.aspx

Your users can be given write access to the drop off library. They do not need access to the final destination library -- the content organizer process will move the on their behalf.

  • i need event receiver because the document keep the same content type but move in different folder depending of a taxonomy field. – user1898765 Jul 2 '14 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.