Thursday, September 24, 2009

Update the List item permission programmatically

Suppose if you have already bind a sharepoint group to a list item in a custom list/library for integrating permission then later on , if you want to modify the permission for that list item, below is the code snippet to achive it.

SPRoleAssignment objRoleAssignment = objListItem.RoleAssignments.GetAssignmentByPrincipal(objSPGroup);
objRoleAssignment.RoleDefinitionBindings.Remove(web.RoleDefinitions["Full Control"]);
objRoleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Contribute"]);
objRoleAssignment.Update();

Samarendra Swain

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Awesome something which will be only post by who know how much pain this small snippet would give on given scenario

    Thank you

    ReplyDelete