Hi All,
I'm trying to create a subsite programatically from a Windows based Client and create non-inherited associated groups for the owner / members and visitors.
In effect - I *think* I'm wanting to create the equivalent of SPWeb.Groups as opposed to SPWeb.SiteGroups that I'd otherwise need in the Server Side world...
I Can create the site ... and groups ... but I'm struggling to set it as the default Owners / Visitors / Members group...
Any help gratefully appreciated....
ClientContext ctx = new ClientContext(ContextPath); WebCollection collWeb = ctx.Web.Webs; WebCreationInformation webCreationInfo = new WebCreationInformation(); webCreationInfo.Title = strSiteTitle; webCreationInfo.Description = "Description of the new Web Site..."; webCreationInfo.Language = 1033; webCreationInfo.Url = strURL; webCreationInfo.UseSamePermissionsAsParentSite = false; webCreationInfo.WebTemplate = "STS#0"; Web oNewWebSite = collWeb.Add(webCreationInfo); ctx.ExecuteQuery(); GroupCreationInformation SPOwnersGroup = new GroupCreationInformation(); SPOwnersGroup.Title = strSiteTitle + " Owners"; SPOwnersGroup.Description = "Use this Group to grant people full control permissions to the SharePoint Site : " + strSiteTitle; Group groupo = ctx.Web.SiteGroups.Add(SPOwnersGroup); ctx.Web.AssociatedOwnerGroup = groupo; ctx.Web.AssociatedOwnerGroup.Update(); groupo.Update(); ctx.ExecuteQuery();
Note - ContextPath, strSiteTitle and strURL are incoming parameters into my "CreateSite" function ...
I don't receive any errors when the above runs .... the group is created - but it doesn't seem to be the associated owner group.