如何以编程方式将用户权限添加到Sharepoint中的列表?我想将权限"Contribute"添加到某个列表的用户或组.我正在使用C#.
您可以使用SPRoleAssignment对象执行此操作,例如
// Assuming you already have SPWeb and SPList objects ... SPRoleAssignment roleAssignment = new SPRoleAssignment("dom\\user", "user@dom", "user", "some notes"); SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Contributor); roleAssignment.RoleDefinitionBindings.Add(roleDefinition); if (!myList.HasUniqueRoleAssignments) { myList.BreakRoleInheritance(true); // Ensure we don't inherit permissions from parent } myList.RoleAssignments.Add(roleAssignment); myList.Update();