I'm adding permissions for a user for a specific SPListItem:

SPRoleAssignment roleAssignment = new SPRoleAssignment(user);

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?

1 Answer 1


I've developed some code to perform this task. Hope it helps somebody.

foreach (SPRoleAssignment roleAssignment in listItem.RoleAssignments)
    if (roleAssignment.Member.LoginName != user.LoginName)

    foreach (SPRoleDefinition roleDefinitionBinding in roleAssignment.RoleDefinitionBindings)
        if (roleDefinitionBinding.Name == "ASpecificRole")
  • 1
    If this answers the original question, please mark is as the answer.
    – moe
    Commented May 20, 2017 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.