Add Custom Permission Level Programmatically
SPSite oSite = new SPSite(<sharepoint site>);
SPWeb oWeb = oSite.OpenWeb();
SPRoleDefinition role = oWeb.RoleDefinitions["Custom Role"];
role.BasePermissions = SPBasePermissions.AddListItems | SPBasePermissions.BrowseDirectories | SPBasePermissions.EditListItems | SPBasePermissions.Open | SPBasePermissions.OpenItems | SPBasePermissions.ViewListItems | SPBasePermissions.ViewFormPages| SPBasePermissions.ViewPages| SPBasePermissions.CancelCheckout| SPBasePermissions.DeleteListItems| SPBasePermissions.ApproveItems;
role.Update();
Comments
- Anonymous
July 08, 2010
Hi SKV thanks a lot for posting this article. i am looking for the same. However, can you clear my doubt. can we assign all the permissions that we see in the site's UI? like we will see list permissions and site permissions category and total they may be around 40. Can we select all those through programatically ? i hope in the above code that you shared, you used only list level permissions pleae clarify my doubt. you can mail me to rajkumar.bathula@gmail.com Regards Raj