Reputation: 11
Now above does not work if user who is adding has rights of contribute but works if users has full control.
I think a solution could be to run these privileged calls by system admin user.
How can i solve this problem , Please guide, Thanks.
//Amit
Upvotes: 1
Views: 1720
Reputation: 131722
Just running your code using RunWithElevatedPrivileges is not enough. Credential info is kept inside the SPSite object that is used directly or indirectly by most SPxxxx objects, including SPWeb, SPListItem etc. In order to modify item permissions you will have to recreate any SPSite, SPListItem, SPWeb you use inside RunWithElevatedPrivileges, using only the IDs provided by the event handler.
Upvotes: 1
Reputation: 748
Have you tried RunWithElevatedPrivileges? Just remember to run as little code as possible within it.
Upvotes: 2