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...
- 
http://sharepointmagazine.net/articles/creating-documents-with-sharepoint-designer-2010-workflows Issue#1 : The workflow could not cr...
- 
clear $site = Get-SPSite -Identity http://url $q = New-Object -TypeName microsoft.SharePoint.SPSiteDataQuery $q.Lists = "<List...
- 
I guess Drawing is my first extra curricular activity which i have developed during the school days. Thanks to Bhargavi Teacher[my Drawing T...
 
No comments:
Post a Comment