This example will create a new permission level, called Example_xxxxxxxxxxx. After creation, it binds the permission level to an existing SharePoint Group called Foo.
using (SPSite site = new SPSite( "http://moss/sites/PermExample" ))
{
using (SPWeb rootWeb = site.RootWeb)
{
string permissionLevelName = "Example_"+System.DateTime.Now.Ticks.ToString();
// Create a new Permission Level
SPRoleDefinition newPermissionLevel = new SPRoleDefinition();
newPermissionLevel.Name = permissionLevelName;
newPermissionLevel.Description = "Example Permission Level";
newPermissionLevel.BasePermissions =
SPBasePermissions.AddListItems |
SPBasePermissions.BrowseDirectories |
SPBasePermissions.EditListItems |
SPBasePermissions.DeleteListItems |
SPBasePermissions.AddDelPrivateWebParts;
// Add the permission level to web
rootWeb.RoleDefinitions.Add(newPermissionLevel);
// Bind to the permission level we just added
newPermissionLevel = rootWeb.RoleDefinitions[permissionLevelName];
// Create a new role Assignment using the SharePoint Group "Foo"
SPRoleAssignment roleAssignment = new SPRoleAssignment( (SPPrincipal)rootWeb.SiteGroups[ "Foo" ] );
// Add the Permission Level to the Foo SharePoint Group
roleAssignment.RoleDefinitionBindings.Add(newPermissionLevel);
// Add the new Role Assignment to the web
rootWeb.RoleAssignments.Add(roleAssignment);
rootWeb.Close();
}
site.Close();
}
Subscribe to:
Post Comments (Atom)
SonarQube with Jenkins Setup using Docker Images
https://funnelgarden.com/sonarqube-jenkins-docker/ https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...
-
The competitive examination for the Indian Forest Service is conducted by Union Public Service Commission (UPSC). IFS exam is conducted ann...
-
Happy New Year. May this year is the year for your dreams, passions, everything you believe, your wishes, your desires, your thoughts, your ...
-
Azure Mobile App Service provides services that allow you to support mobile apps across multiple platforms. It does not provide hosting ser...
No comments:
Post a Comment