当我删除列表中组的角色分配时,这也会删除子文件夹的角色分配。(对于子文件夹,BreakInheritance == True。)
我的代码:
//BreakRoleInheritance on list
list.BreakRoleInheritance(true);
//Initiate a roledefinition for read only
SPRoleDefinition readerRoleDef = web.RoleDefinitions.GetByType(SPRoleType.Reader);
//Creates a roleassignment bound to the group
SPRoleAssignment readerRole = new SPRoleAssignment(group);
//Add the definition to the roleassignment
readerRole.RoleDefinitionBindings.Add(readerRoleDef);
//Gets the roledefinitions for the given group
var roleAssignements = list.RoleAssignments.Cast<SPRoleAssignment>().Where(r => r.Member.ID == group.ID);
//I would like to to something like this, but this code here affects roleassignments on subfolders as well:
roleAssignements.ToList().ForEach(r => list.RoleAssignments.RemoveById(r.Member.ID));
//Add the new, read role assignment
list.RoleAssignments.Add(readerRole);
//Save changes to the list
list.Update();
有人可以指出我正确的方向吗?