I have a requirement to programmatically simulate the "Specific people" functionality using CSOM or PnP. (Please refer to the screenshot for the Specific people option).
I tried the following programmatically however it generates only Anonymous Link which does not help in my situation as the user is always tracked as "Guest User".
My requirement is to send unique links to each external user identified by email id and when there is a change made to the document by the external user, I need to track them.
Code used by me is,
public void ShareTheDocument(ClientContext context, List<string> emails, string absoluteDocUrl)
{
var userRoles = new List<UserRoleAssignment>();
foreach (var user in emails)
{
UserRoleAssignment role = new UserRoleAssignment();
role.UserId = user;
role.Role = Role.Edit;
userRoles.Add(role);
}
IList<UserSharingResult> userSharingResults = DocumentSharingManager.UpdateDocumentSharingInfo(context, absoluteDocUrl, userRoles, false, true, true, "New Document - 1", true, false);
context.ExecuteQuery();
}
PLEASE HELP. Thank you.