And even when I tried to do it programmatically using SPWeb.CreateDefaultAssociatedGroups, it still creates only two groups.
So I ended up with the following code snippet:
var primaryAdmin = web.SiteAdministrators[0]; var groupName = SPResource.GetString("DefaultVisitorGroupName", new object[] { SPHttpUtility.HtmlEncode(web.Title) }); var groupDescription = SPResource.GetString("DefaultVisitorGroupDescriptionRichText", new object[] { SPHttpUtility.HtmlEncode(web.Title), SPHttpUtility.HtmlUrlAttributeEncode(SPHttpUtility.UrlPathEncode(web.ServerRelativeUrl, false)) }); web.SiteGroups.Add(groupName, primaryAdmin, null, groupDescription); web.AssociatedVisitorGroup = web.SiteGroups[groupName]; var roleAssignment = new SPRoleAssignment(web.AssociatedVisitorGroup); web.RoleAssignments.Add(roleAssignment); roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Read"]); web.AllowUnsafeUpdates = true; roleAssignment.Update();
It creates Visitors group and gives it Read permissions.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.