I'm adding permissions for a user for a specific SPListItem
:
SPRoleAssignment roleAssignment = new SPRoleAssignment(user);
roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["ASpecificRole"]);
listItem.RoleAssignments.Add(roleAssignment);
listItem.Update();
I'm giving it a name to distinguish on which basis does he have the access, because he can also be provided access to the same resource from other part of the system.
I want to be able then to remove the specific type of the assignment for this particular user but without touching his permissions gained from other entitlements (which can give him the same type of access e.g. "Read").
The problem is when I access listItem.RoleAssignments
I can only index them by number and when using listItem.RoleAssignments.Remove
I can only remove it by index or by SPUser
object.
Is it possible to get the specific Role Assignment with the name I've given it when adding?
Or is there a better approach?