Forum Discussion
Karim786
Aug 08, 2022Copper Contributor
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...
Karim786
Aug 08, 2022Copper 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();
}kalpeshvaghela
Aug 08, 2022Iron 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.