Freigeben über


HOW TO: Add users to SharePoint Groups using SharePoint 2013 UserGroup.asmx Web Service

This post is a contribution from Raghavendra B Nanjaiah, an engineer with the SharePoint Developer Support team.

Problem

When you try to add users through the UserGroup.asmx web service (https://localhost/_vti_bin/UserGroup.asmx) in SharePoint 2013 with the sample code below.

 sp.UserGroup usrgrpService = new sp.UserGroup();
 usrgrpService.Credentials = new System.Net.NetworkCredential("Administrator", "access", "contoso");
  
 usrgrpService.AddUserToGroup("Dev Members", "usera",
 "contoso\\usera", "usera@contoso.com", "Notes");

You will successfully add user to the SharePoint group, but if you look at the user permission or try accessing site using this user credentials, you’ll get “Site is not shared with you” message.

Solution

You have to pass user in claims encoded format (e.g., i:0#.w|contoso\chris) in SharePoint 2013.  This is because claims authentication is enabled in the web applications you create by default.

Not that this is something that many don’t know, but we’ve had customers reporting this issue to us and we thought we’ll get this message out!

HTH

Comments

  • Anonymous
    November 27, 2014
    hai
  • Anonymous
    November 27, 2014
    hai