Thursday, August 4, 2011

Remove roles from Sharepoint list item

void SetReadonly(SPListItem FinalizeItem, SPWeb web)
        {
            //void SetReadonly(SPListItem FinalizeItem)

            //SPFile file = Folder.Files[fileName];
            SPListItem item = FinalizeItem;

            string groupName = string.Empty;

            if (!item.HasUniqueRoleAssignments)
            {
                item.BreakRoleInheritance(true);
            }
            SPRoleAssignmentCollection SPRoleAssColn = item.RoleAssignments;


            for (int i = SPRoleAssColn.Count - 1; i >= 0; i--)
            {
                if (!(SPRoleAssColn[i].Member.Name.Equals("Viewers"))
                {
                    SPRoleAssColn.Remove(i);
                }
            }

            //item.RoleAssignments.Add(RoleAssignment);
            //item.Update();
        }

No comments:

Post a Comment

Followers

Blog Archive