Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

AssociatedOwners group don't have permission to SharePoint site

$
0
0

Hi,

I am creating a SharePoint 2013 site using CSOM and assigning the already existing group("SP Owners") as the AssociatedOwnerGroup, AssociatedMemberGroup and AssociatedVisitorGroup to the site. The group is assinged as the AssociatedOwnerGroup, AssociatedMemberGroup and AssociatedVisitorGroup to the site ( I checked the _layouts/15/permsetup.aspx page) but the problem is that this group does not have any access to the site.

Below is the code snippet that I am using.

SP.WebCollection collWeb = clientContext.Web.Webs;
clientContext.Load(collWeb);

SP.WebCreationInformation webCreationInfo = new SP.WebCreationInformation();
webCreationInfo.Title = webName;
webCreationInfo.Description = "A site created by template.";
webCreationInfo.Language = 1033;
webCreationInfo.Url = webName;
webCreationInfo.UseSamePermissionsAsParentSite = false;
webCreationInfo.WebTemplate = templateID;


SP.Web oNewWebsite = collWeb.Add(webCreationInfo);
clientContext.ExecuteQuery();

clientContext.Load(oNewWebsite);
clientContext.ExecuteQuery();

SP.GroupCollection siteGroups = oNewWebsite.SiteGroups;
SP.Group ownerGroup = siteGroups.GetByName("SP Owners");
oNewWebsite.AssociatedOwnerGroup = ownerGroup;                       
oNewWebsite.AssociatedOwnerGroup.Update();
oNewWebsite.AssociatedMemberGroup = ownerGroup;
oNewWebsite.AssociatedMemberGroup.Update();
oNewWebsite.AssociatedVisitorGroup = ownerGroup;
oNewWebsite.AssociatedVisitorGroup.Update();
ownerGroup.Update();
oNewWebsite.Update();
clientContext.ExecuteQuery();

where webName and templateID are the parameter to the function and "SP Owners" is the existing group within the site collection.

Any help will be appreciated.

Thanks,

NKJ



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>