Scenario
Sometimes we donot have admin right on server.In this case we need to make request to install our farm solution in the site.But whats about the Group?
Sometimes we donot have admin right on server.In this case we need to make request to install our farm solution in the site.But whats about the Group?
If you need to maintain 50 groups then we need to go to the custom development where as soon feture is activated the groups are created in the site
Below code snippet explains that how to add a group in SharePoint Programmatically.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb spWeb = SPContext.Current.Site.RootWeb)
{
try
{
spWeb.SiteGroups.Add("Custom Group", spWeb.CurrentUser, null, "Custom Group Test Description");
SPRoleAssignment spRoleAssignment = new SPRoleAssignment(spWeb.SiteGroups["Custom Group"]);
SPRoleDefinition con = spWeb.RoleDefinitions["Contribute"];
spRoleAssignment.RoleDefinitionBindings.Add(con);
spWeb.RoleAssignments.Add(asgn);
}
catch (SPException ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
spWeb.Update();
}
}