Urgent Please - Extrnal user not beeing added to site using CSOM 16.1

Omri Kaufman 1 Reputation point
2021-06-17T07:20:17.113+00:00

I am trying to add permission to a folder using the csom 16.1
with this line of code
DocumentSharingManager.UpdateDocumentSharingInfo(spContext, fullUrl,userRoleAssignmentList, true, true, true, null, false, false)

I am not getting any errors and all other permission are working perfectly, only the external users are not being added.

I tried to Change my site sharing configuration to be "New and existing guests – guests must sign in or provide a verification code"
but still noting is working

Please can some tell me if something changed

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,803 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,031 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,091 Reputation points Microsoft Vendor
    2021-06-18T09:33:46.257+00:00

    Hi @Omri Kaufman ,

    We need to check “Limited-access user permission lockdown mode“ is deactivate. Otherwise the folder is unable to be shared with external users.
    Go to site Contents>Site Settings>Site Collection Features
    106960-image.png

    And Change your site sharing configuration to be "Anyone – Users can share files and folders using links that don’t require sign-in"

    Here is code for sample:

            var users = new List<string>() { "user1", "user2 " };  
    
            var userRoles = new List<UserRoleAssignment>();  
            foreach (var user in users)  
            {  
                clientContext.Web.EnsureUser(user);  
                UserRoleAssignment role = new UserRoleAssignment();  
                role.UserId = user;  
                role.Role = Role.View; //Role.Edit  
                userRoles.Add(role);  
            }  
    
            string absoluteFileUrl = "folderurl";  
            DocumentSharingManager.UpdateDocumentSharingInfo(clientContext, absoluteFileUrl, userRoles, true, true, true, "Test Folder", true, true);  
            clientContext.ExecuteQuery();  
            Console.WriteLine("success");  
            Console.ReadLine();  
    

    And the code will send an email to user’s mailbox. But it can only add permission to existing external users.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Omri Kaufman 1 Reputation point
    2021-07-04T06:20:56.407+00:00

    so for the customers that are using my company tool Cloudsfer.com migration tool all is working and the limit access solved the problem, for new and existing external users, but for my domain when I am adding permission to external users that are not is my domain i am still not getting an invitation.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.