Hi All,
following example will demonstrate , how we can create the Custom Permission Level Programmatically in SharePoint .
public static void CreateCustomPermissionLevel()
{
try
{
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPRoleDefinition role = new SPRoleDefinition();
role.Name = "AddEdit";
role.Description = "Description: Custom Permission level";
role.BasePermissions = SPBasePermissions.AddAndCustomizePages | SPBasePermissions.ApplyStyleSheets | SPBasePermissions.AddListItems | SPBasePermissions.EditListItems | SPBasePermissions.ViewListItems | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions | SPBasePermissions.CreateAlerts | SPBasePermissions.ViewPages;
web.RoleDefinitions.Add(role);
}
}
}
catch (Exception ex)
{
// Error Logging
}
}
Thanks.
following example will demonstrate , how we can create the Custom Permission Level Programmatically in SharePoint .
public static void CreateCustomPermissionLevel()
{
try
{
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPRoleDefinition role = new SPRoleDefinition();
role.Name = "AddEdit";
role.Description = "Description: Custom Permission level";
role.BasePermissions = SPBasePermissions.AddAndCustomizePages | SPBasePermissions.ApplyStyleSheets | SPBasePermissions.AddListItems | SPBasePermissions.EditListItems | SPBasePermissions.ViewListItems | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions | SPBasePermissions.CreateAlerts | SPBasePermissions.ViewPages;
web.RoleDefinitions.Add(role);
}
}
}
catch (Exception ex)
{
// Error Logging
}
}
Thanks.
0 comments:
Post a Comment