SharePoint Asked by Marlou on November 8, 2021
Does anyone know if it’s possible to invite external users with the client object model or is this only possible in the UI?
Not by CSOM but you can invite a Guest user by using PowerShell along with Azure Function or Azure logic app service.
Answered by cjs on November 8, 2021
Please see an example below:
private void ShareTheWeb(ClientContext context, List<string> emails)
{
var users = emails.Select(email =>
new UserRoleAssignment
{
UserId = email,
Role = Role.View
});
WebSharingManager.UpdateWebSharingInformation(context, context.Web, users.ToList(), true, null, true, true);
context.ExecuteQuery();
}
private void ShareTheDocument(ClientContext context, List<string> emails, string absoluteDocUrl)
{
var users = emails.Select(email =>
new UserRoleAssignment
{
UserId = email,
Role = Role.View
});
DocumentSharingManager.UpdateDocumentSharingInfo(context, absoluteDocUrl, users.ToList(), true, true, true, null, true, true);
context.ExecuteQuery();
}
Answered by Roman on November 8, 2021
Right now there is no way to add external user programmatically or using CSOM.The reasom behind it seems that SPO Webservice wont provide a mechanism to do this.
Answered by Aanchal on November 8, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP