0

For sharepoint, we are trying to get files within a given list id along with its roleAssignments information.

For this, we are using REST API /Lists(guid'list_ID')/items?$expand=File&$select=*,hasuniqueroleassignments. This expands files objects in the response and also has the flag HasUniqueRoleAssignments, which gives information on the permission inheritance.

However, for sharepoint 2013, the same API does not expands the File objects in the response when used with the select param. Hence, we need to make two API calls, first for expanding files and then to fetch information on role assigments on each of the file.

Is there any other work around or other parameter that we can use for sharepoint 2013 to get this information in one API call?

0

As you say, HasUniqueRoleAssignments is just a flag that tells you whether or not the item has unique permissions.

In order to get the actual permission information, you would need to also expand the RoleAssignments property itself:

_api/web/lists(guid'list-id')/items?$expand=File,RoleAssignments&$select=*,hasuniqueroleassignments

You still might have to add additional params to the $select or $expand in order to get information you find useful, from my quick test in Postman, expanding RoleAssignments results in a couple properties that have __deferred URIs, and the single PrincipalId property that actually has data, which I guess could be useful if you already know the user IDs of relevant users, or else you would have to make an additional query to get more detailed user information.


To address your additional question from the comments:

i want to understand if the file is inheriting permission from its parent folder/list. Do we have any such property in RoleAssignments thats will help?

There is a property that will tell you that information, but it's not within RoleAssignments. You're already getting that property - it's the HasUniqueRoleAssignments property itself that will tell you.

If HasUniqueRoleAssignments is true, then it is not inheriting permissions, it has unique permissions.

If HasUniqueRoleAssignments is false, then it does not have unique permissions, and therefore is inheriting permissions from a parent object, whether that be a folder, or the document library it is in, or the parent web site where the document library is.

If HasUniqueRoleAssignments is false you can check the FirstUniqueAncestorSecurableObject property to find out exactly which object the file is inheriting its permissions from.

3
  • Thats correct! however, i want to understand if the file is inheriting permission from its parent folder/list. Do we have any such property in RoleAssignments thats will help?
    – Nidhi Teli
    Jun 4 at 4:15
  • @NidhiTeli updated my answer. Jun 4 at 14:54
  • Thank you for the quick response. This really helped understanding the hierarchy for an objects in sharepoint.
    – Nidhi Teli
    Jun 8 at 5:01

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.