0
votes

I aim to remove a user's direct access to a Sharepoint folder using typescript. I am occupying sp-pnp-node and @ pnp / login. I can already assign the permissions without any problem, but I can't find the way for remove it :(

Example

The user does not belong to any group and has specific permissions per folder.

1
Tried to improve the question text. - B--rian

1 Answers

0
votes

This should get you what you need:

Use import "@pnp/sp/security"; to load the PnP security module.

const userToRemove = //get a reference to the user object for the user

sp.web.roleAssignments.expand("Member").get().then(function(assignments) { 
    assignments.forEach(function(role) {
        if (role.Member.Id == userToRemove.Id) {
            await list.roleAssignments.getById(role.Id).delete();
        }
    });
});

For more details on the security module, see https://pnp.github.io/pnpjs/sp/security/#role-assignments