Ads

Saturday, 23 March 2013

C# code to create a custom permission level for a specific SharePoint site programmatically

Create a custom permission level for a specific SharePoint site :
using (SPSite osite = properties.Feature.Parent as SPSite) 
{
  using (SPWeb oweb = osite.OpenWeb())      
  {
     SPRoleDefinition roleDefinition = new SPRoleDefinition(); 
     roleDefinition.Name = "Custom Permission Level";      
     roleDefinition.Description = "Desc Here";  
     roleDefinition.BasePermissions =   SPBasePermissions.AddAndCustomizePages |    SPBasePermissions.ApplyStyleSheets | SPBasePermissions.CreateGroups;                     oweb.RoleDefinitions.Add(roleDefinition);  
  }
}

No comments:

Post a Comment

Ads