I have the following code to add a group with a permission level to a sharepoint list
SPGroup Contribute = web.SiteGroups["Staff"];
SPRoleDefinition ContributeDefinition = web.RoleDefinitions["Read"];
SPRoleAssignment ContributeRoleAssignment = new SPRoleAssignment(Contribute);
ContributeRoleAssignment.RoleDefinitionBindings.Add(ContributeDefinition);
list.RoleAssignments.Add(ContributeRoleAssignment);
which adds the group, but how would I do it if I want to revoke the permission to the list for this group?
thanks in advance
If you need to remove whole role assgnment you can do:
If you need to revoke some definition binding you can do:
If that is not you want, please describe in more details.
UPDATE:
Here is the sample code which I’ve tested and it works. It will remove Contribute role and add Read role to target group. Please note, that I have non-english Sharepoint version, so ensure the names of roles.