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?

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.

  • 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 '16 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();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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