4
using (SPSite site = (SPSite)properties.Feature.Parent)
{
using (SPWeb web = site.OpenWeb())
{
if (web != null)
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["Alert Status v1.0"];
//Creates a new role assignment for a group
SPGroup myGroup = web.SiteGroups["IKM Manager"];
SPRoleAssignmentCollection roleAssignments = web.RoleAssignments;
// SPRoleAssignment accepts a SPPrincipal which can be a SPUser or SPGroup
SPRoleAssignment roleAssignment = new SPRoleAssignment(myGroup);
//Add the new role assignment to the collection of role assignments for the site.
roleAssignments.Add(roleAssignment);
// Stop inheriting permissions
list.BreakRoleInheritance(true);
list.RoleAssignments.Add(roleAssignment);
list.Update();
我在RoleAssignments.Add(roleAssignment)上發生錯誤,如「無法添加具有空角色定義綁定集合的角色分配」。我想停止繼承權限並將特定的組添加到列表權限。你可以幫我嗎?請..如何將特定SharePoint組添加到列表權限
感謝
值得更多的選票。 – 2012-10-03 13:26:37
是否可以在OfficeDev/PnP中執行此操作?例如對於SharePoint Online。 – Hybris95 2016-09-30 13:53:22