Forum Discussion
Removing user from Sharing Links
Hello,
Is it possible to delete user from "Sharing Links" programmatically?.
Sharing Links are created by selecting a document and folder and clicking Share button.
I have noticed that it creates a Sharepoint group in the backend, but removing user from this Sharepoint group does not remove the user from sharing link.
What worst is if we remove the whole sharing link, it does not delete the link permanently, so in future if someone share the same document again it restores the deleted sharing link.
Thanks for your help.
Regards,
Karim
3 Replies
- kalpeshvaghelaIron Contributor
I have tried removing whole Sharing Link and tried to share same document again and here it's generating different link. So how have you validated that if we remove sharing link and resharing it again, it uses same link?
How have you tried to remove sharing link?
- Karim786Copper Contributor
Thanks for your response
I want to remove it programmatically, I am using this code using csom and it is not removing it properly.
_ctx.Load(_ctx.Web, p => p.Title); _ctx.ExecuteQuery(); string sname= _ctx.Web.Title; ListItem li = _ctx.Web.GetListItem(url); IEnumerable<RoleAssignment> roles = _ctx.LoadQuery(li.RoleAssignments.Include(roleAsg => roleAsg.Member, roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name))); _ctx.ExecuteQuery(); IEnumerable<RoleAssignment> rolesfiltered = roles.Where(i => i.Member.LoginName.StartsWith("SharingLinks")); _ctx.ExecuteQuery(); foreach (RoleAssignment ra in rolesfiltered) { ra.DeleteObject(); _ctx.ExecuteQuery(); }- kalpeshvaghelaIron Contributor
If it's one time job then you can remove it from UI. Below are the steps:
Step 1: Select folder or document and go to "Manage Access"
Step 2: Click on Setting icon for the sharing link which you want to delete
Step 3: Click on Delete icon
Hope it will helpful to you.