Reputation: 13
I have written a piece of code to create a custom security group in a SharePoint app. the code runs on feature activation at Site level and is as follows:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = (SPSite)properties.Feature.Parent;
using (SPWeb web = site.OpenWeb())
{
if (!GroupExists(web.SiteGroups, "Test Column Administrators"))
{
web.SiteGroups.Add("Test Administrators", web.AssociatedOwnerGroup, null, "Contains users and groups who can administer Test Column articles.");
web.AssociatedGroups.Add(web.SiteGroups["Tets Column Administrators"]);
web.Update();
}
}
}
The code does create that group and adds it to the SharePoint site however when I go to Site Actions->Site Permissions (_layouts/user.aspx page), that group is missing. But when I manually go to the groups.aspx page (_layouts/groups.aspx) it is there.
How can I get my code to create that group in such a way that it appears in the user/aspx page as well?
Thanks in advance
Upvotes: 0
Views: 2135
Reputation: 866
That is completely OK. The Groups page displays the list of groups that actually exist in the Site. And the page Users.aspx displays what Permissions the principals have within this Site. Your code is OK but you have to add more code that grants permissions to your group if it needs permissions. When your group has permissions within the site it will appear on the Users.aspx page. See a sample how to add permissions to and item, same is for Site level and web level.
Upvotes: 1