在为Sharepoint列表上的组分配权限后,该组的用户在尝试访问网站上的任何列表时都会遇到上述错误。
下面我用来为列表中的组分配权限的代码没有任何错误地退出,并将RoleAssignments添加到列表和ClientContext.Web:
BasePermissions permissions = new BasePermissions();
permissions.Set(PermissionKind.ViewListItems);
RoleDefinitionCreationInformation rdcInfo = new
RoleDefinitionCreationInformation();
rdcInfo.Name = "roleDefName";
rdcInfo.Description = "Description";
rdcInfo.BasePermissions = permissions;
RoleDefinition roleDefinition = clientContext.Site.RootWeb.RoleDefinitions.Add(rdcInfo);
RoleDefinitionBindingCollection RoleDefinitionBindingColl = new RoleDefinitionBindingCollection(clientContext);
RoleDefinitionBindingColl.Add(roleDefinition);
List targetList = web.Lists.GetByTitle(listTitle);
targetList.BreakRoleInheritance(true, false);
RoleAssignmentCollection collRoleAssign = targetList.RoleAssignments;
RoleAssignment rollAssign = collRoleAssign.Add(group, RoleDefinitionBindingColl);
web.RoleAssignments.Add(group, RoleDefinitionBindingColl);
web.Update();
clientContext.ExecuteQuery();
只有通过上面的代码分配了权限的用户会收到错误。