Pnpjs: Sharepoint rest api - remove external user

Created on 5 May 2020  路  5Comments  路  Source: pnp/pnpjs

Category

  • [x] Enhancement
  • [ ] Bug
  • [x] Question
  • [ ] Documentation gap/issue

Hello,

I'd like to know if it's possible to remove an external user from a folder.

I granted access to the folder with the SP.Web.ShareObject method which accepts the peoplePickerInput parameter (whereyou can define all the users to invite).

I found the SP.Web.UnshareObject method but it accepts only the item url parameter, so you cannot specify the users.

pnp.sp.web.unshareObject("https://mysite.sharepoint.com/sites/dev/Docs/test.txt").then((result: SharingResult) => {

    console.log(result);
}).catch(e => {
    console.error(e);
});

Is there any solution for this ?

Thanks.

enhancement question

Most helpful comment

That sounds correct. Unshare doesn't retract permissions from a specific user but stops document sharing to any previously added shares. It's the projection of the following action in the UI:

image

which has no option to exclude person-wise.

In the UI it's also not possible to exclude a specific individual but to remove the share or share link completely.

image

Maybe using custom permissions is the case to consider?

However, I'm not deeply familiar with the modern sharing feature. But after a brief look into the calls and UI I got the impression described above.

All 5 comments

That sounds correct. Unshare doesn't retract permissions from a specific user but stops document sharing to any previously added shares. It's the projection of the following action in the UI:

image

which has no option to exclude person-wise.

In the UI it's also not possible to exclude a specific individual but to remove the share or share link completely.

image

Maybe using custom permissions is the case to consider?

However, I'm not deeply familiar with the modern sharing feature. But after a brief look into the calls and UI I got the impression described above.

@koltyakov

Hello Andrew,

Thanks for your reply.

Normally the site owners can do that as you can see from here:

image

But I couldn't find the related method.

I got it, thanks, I chose an incorrect share type which doesn't support removing individuals.
Specific people sharing allows such an action. The removing is happening using the same method as for sharing with inviteesToRemove property in the payload.
Looks like something which we do not cover at the moment and which can be added as an enhancement:
image

Ok I understand.
I'll use the removeByLoginName/removeById on the siteusers collection for now.
Thanks for your answers.

Going to close this as answered, thanks! If you are still stuck please open a new issue and ref this with any additional details. Thanks!

Was this page helpful?
0 / 5 - 0 ratings