Posts

Showing posts with the label item level permission programatically

SharePoint 2010: Setting Item Level Permission on a List Folder

Image
Scenario: Sometime we run into a situation where we got to set a item level permission on a particular folder in a list. Possible reason to that can be hiding data from other users, if the folder is owned by a specific user and contain some private information.  About the Code: In the following, I had a similar, aforementioned, requirement with a slight punch of a management group that was suppose to view everything and then I had normal users, among whom, the owner of the folder was suppose to have rights to viewing and contributing. Thus I had to set permissions for the users who owned the folder and then for the management group. BTW originally it was a sand-boxed solution.  private void setPermissions(SPFolder folder) { SPGroupCollection spc = web.SiteGroups; //Break the role inheritance in order to assign individual rights on folders if (!folder.Item.HasUniqueRoleAssignments) { folder.Item.BreakRoleInheritance(true); }...