Can we set custom permission of a list using features in sharepoint 2010? -
I am working on SharePoint 2010. Creating Features To Automate Custom List Building I have been assigned a task to automatically set custom permissions for each list automatically using the features. I would like to know if this is possible and if yes,
here are two things:
- Custom permit levels have to be created with permissions for contributions
- This permission and default available permissions have to be set to those lists, which are custom made using the features.
Please specify which methods to possibly be overridden if you are thankful in advance for your valuable answers
Override the feature With the same type of code as the following:
Public override Zero FeatureActivated (SPFeatureReceiverProperties properties) {SPWeb Web = (SPWeb) property. Fetcher Parent; SPList List = web.GetList (web.Url + "/ Lists / MyList"); SPRoleDefinition role def = new SPRoleDefinition (); RoleDef.BasePermissions = SPBasePermissions.DeleteListItems | | SPBZPromission. Adult Items | SPBasePermissions.EditListItems; RoleDef.Description = "Custom permissions deployed by facility"; RoleDef.Name = "contribution-delete"; Web.RoleDefinitions.Add (roleDef); RoleDef = web.RoleDefinitions [roleDef.Name]; SPMember Owner = Web Site users [@ "domain \ username"]; SPUser user = web.SiteUsers [@ "domain \ user name"]; Web.SiteGroups.Add ("Contribute-Delete", owner, user, "A group to delete contributions"); SPGroup ContributeDial Group = WebSite Group group ["contribution-delete"]; SPRoleAssignment Role Assignment = New SPRoleAssignment (Contribute DeleteGroup); RoleAssignment.RoleDefinitionBindings.Add (roleDef); List.BreakRoleInheritance (right); List.RoleAssignments.Add (ContributeDeleteGroup); }
Comments
Post a Comment