I have a list (mylist) which inherits custom groups with custom permission levels from the site the list is located in.
Now I would like to change the custom permission of only one of the groups (groupToChange) and only for this specific list (mylist).
I wonder if I would get there ok with the below code:
SPList mylist = web.Lists["MyList"];<br> SPGroupCollection spgc = SharePointConfiguration.Site.SiteGroups;<br> SPGroup group = spgc[groupToChange];<br> SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)group);<br> mylist.Item.BreakRoleInheritance(true);<br> roleAssignment.RoleDefinitionBindings.Add(SharePointConfiguration.Site.RoleDefinitions["New Permission Level"]);<br> mylist.Item.RoleAssignments.Add(roleAssignment); mylist.Update();