Monday, June 3, 2013

Adding Authenticated Users to Sharepoint Group


SPWeb grpWeb = properties.Parent as SPWeb;
string strPermissionLevel = "Read";
grpWeb .SiteGroups.Add("PMOGroup", owner, owner, "PMOUsers");
SPRoleAssignment roleAssignment = new SPRoleAssignment(grpWeb .SiteGroups["PMOGroup"]);
roleAssignment.RoleDefinitionBindings.Add(grpWeb .RoleDefinitions[strPermissionLevel]);
grpWeb .RoleAssignments.Add(roleAssignment);
grpWeb .Update();

// "c:0(.s|true" = All authenticated users

grpWeb .SiteGroups["PMOGroup"].AddUser("c:0(.s|true", string.Empty, string.Empty, string.Empty)

No comments:

Post a Comment