Specifying Item Level Permissions using Sharepoint List Event Handler but to a list on which user has Contribute rights

孤街醉人 提交于 2019-12-24 09:46:46

问题


  1. I have a List to which users have contribute rights
  2. I have a Event Handler which changes the Item Level Permissions on adding or Updating events on list by 2.a CurrentlistItem.BreakRoleInheritance(true); 2.b and by adding users to that list

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


回答1:


Have you tried RunWithElevatedPrivileges? Just remember to run as little code as possible within it.




回答2:


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.



来源:https://stackoverflow.com/questions/3111590/specifying-item-level-permissions-using-sharepoint-list-event-handler-but-to-a-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!