.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Creating a Custom Permission Level in Sharepoint 2010

Posted By:Sunil Yadav       Posted Date: February 28, 2011    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

This article explains how we can create Creating a Custom Permission Level in Sharepoint 2010.

In one of my project there was a requirement to create a Custom permission when creating a new site from site definition. Here is the solution to above. Here i am creating custom permisson and groups using Client object model.

1. Create a new Sharepoint 2010 project and select blank sharepoint 2010 project.

2. Specify a site to deploy the solution.

3.Right click on the project and add reference to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

4. Right click on the feature section and new Feature.

5. Right click on newly created feature and add event receiver.

6. Add below code in the event reciever class and deploy the project.

  private void CreatePermission()
            using (OM.ClientContext context = new OM.ClientContext(SPContext.Current.Site.Url))
                OM.BasePermissions permissions = new OM.BasePermissions();
                OM.PermissionKind permissonkind = OM.PermissionKind.AddListItems | OM.PermissionKind.ApproveItems | OM.PermissionKind.BrowseUserInfo | OM.PermissionKind.ManageLists | OM.PermissionKind.ManagePermissions |
                                                  OM.PermissionKind.Open | OM.PermissionKind.ViewFormPages | OM.PermissionKind.ViewPages | OM.PermissionKind.ViewVersions | OM.PermissionKind.EnumeratePermissions | OM.PermissionKind.EditListItems | OM.PermissionKind.DeleteListItems;

                OM.RoleDefinitionCreationInformation roledefinition = new OM.RoleDefinitionCreationInformation();
                roledefinition.Name = "Administrator";
                roledefinition.Description = "This is site administrator Permission.";
                roledefinition.BasePermissions = permissions;

                OM.RoleDefinition role = context.Web.RoleDefinitions.Add(roledefinition);

        private void CreateGroup(OM.RoleDefinition roledefinition)
            using (OM.ClientContext context = new OM.ClientContext(SPContext.Current.Site.Url))
                OM.GroupCreationInformation groupinfo = new OM.GroupCreationInformation();
                groupinfo.Description = "This is administrator group.";
                groupinfo.Title = "Administrator";
                OM.Group group = context.Web.SiteGroups.Add(groupinfo);
                OM.RoleDefinitionBindingCollection rdb = new OM.RoleDefinitionBindingCollection(context);
                context.Web.RoleAssignments.Add(group, rdb);


Add the above code in FeatureActivated event.

public override void FeatureActivated(SPFeatureReceiverProperties properties)

7. Browse to site permission and you will see new created group. Naviage to site permissions to check newly created permission for the site.

Newly created site permissions.


Browse the permission included in the newly created permission.


Newly created group

References :

http://msdn.microsoft.com/en-us/library/bb861862(office.12).aspx http://msdn.microsoft.com/en-us/library/ff382738(office.12).aspx Happy


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend