2

I'm looking for a good way to remove all list item permissions on a certain list item of a specific role type using the JavaScript object model.

With myListItem.get_roleAssignments().getByPrincipal(myUser).deleteObject(); I can delete the permission for a certain user. I'm looking for a way to delete all permissions of a certain role type (eg SP.RoleType.contributor).

0

The closest thing I can think of is this pseudocode:

  1. foreach roleAssignment 'rA'
  2. foreach roleDefinitionBinding 'rDb' in rA.get_roleDefinitionBindings()
  3. Check if user has the base permissions associated with the contributor role by repeatedly using rDb.has(...) which checks for a base permission
  4. if true, delete current roleAssignment from listItem

An example of the check in 3: if(rDb.has(SP.PermissionKind.editListItems) && rDb.Has(...) && ...). The relation between permission level (Contributor) and its permissions can be found somewhere in the settings of your site collection, or here. The SP.PermissionKind enumeration can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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