0

one of our customers sent us a requirement where their users must be able to "Upload/Add" documents, but can't delete those or any other documents. However, at the same time, the user must be able to "Move" those documents into folders (pre-existing ones).

To be clear, the move operation is done by some code that we wrote (to handle "move" and metadata change at the same time, I won't go into details since they don't add anything to this question). To perform the move operation we use

SPListItem.File.MoveTo(folderUrl);

Which works if the user have permission to "Delete" files, but doesn't work if we get rid of that setting.

Without using Elevated privileges, does anybody knows if there is a way to temporarily give "Delete" permission and remove it right away (after the move operation)? Or is there any other approach to do want I'm asking?

Thanks in advance

1

How about if you implement a custom action entitled 'Move' against a document item.

When the user clicks Move then the custom page that is triggered runs as the SharePoint system (through run with elevated privileges) and moves the document appropriately.

  • This wasn't exactly what I did, but was the closest one. The custom move operation was already built, so I just needed elevated privileges on the SPListItem it self, AllowUnsafeUpdates on the item SPWeb and finally call SP MoveTo() – João Gala Louros Oct 15 '12 at 18:54
1

You could have the code temporarily implement item level security on the item being moved and grant the user delete permissions for the duration of the move. Naturally, you would have to pull that permission back off once it had been moved and re-inherit security on the item. Otherwise, you would quickly hit the SharePoint ACL boundary.

1

How about leaving them the Delete permission (IE - normal Contribute), but setting up an ItemDeleting event receiver on that list which aborts the action for non-authorized users?

SPFile.MoveTo() does not trigger ItemDeleting or ItemDeleted, by the way.

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.