1

Does anyone know if it's possible to invite external users with the client object model or is this only possible in the UI?

3 Answers 3

0

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.

1
  • Is this still the case 2 years on? I need to do this and still can't find a way that will allow inviting external users programmatically..?
    – Jaymz
    Oct 10, 2016 at 12:45
0

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();
}
0

Not by CSOM but you can invite a Guest user by using PowerShell along with Azure Function or Azure logic app service.

https://docs.microsoft.com/en-us/azure/active-directory/external-identities/b2b-quickstart-invite-powershell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.