0

I am developing one SPFx web part wherein I am showing all the folders which the logged-in user has access to. And I have a couple of folders in one document library(IT Docs) and some of the folders have unique level permissions i.e. those folders are shared with some users.

I am trying to login using admin credentials who have access to all the folders. Now, I have one people picker textbox where I can type the user name, and based on the user selection I want to show all of the folders of that user.

I am able to fetch the folders using the below code:

let folders: any[] = await sp.web.lists.getByTitle("IT Docs")
      .items
      .filter('FSObjType eq 1')
      .select('FileLeafRef', 'FileRef')
      .get();

And I want to check whether the folder has permissions to the user which is selected in people picker textbox. Can anybody please suggest me how to achieve the same using pnp/sp library using react js?

FYI, Below is the link which I am referring and using which I was able to check whether the library has permissions to the user but couldn't find the way to check folder has permission to the user. :(

https://pnp.github.io/pnpjs/sp/permissions/

Please help.

Thanks in Advance.

1 Answer 1

2

You could use

item.userHasPermissions(LoginName,PermissionKind)

to check user permission for the folder item.

Check @pnp/sp/security

https://pnp.github.io/pnpjs/sp/security/

Your Answer

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

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