Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

WSS UserGroup WS error: Adding a user to a WSS subsite

  Asked By: Palash    Date: Mar 25    Category: Sharepoint    Views: 1812

Based on what I've been able to find in the WSS SDK, the only way to
programmatically and remotely add a user to site is to add them to a
cross-site group using the UserGroup web service. The only method call is
wsUserGroup.AddUserToGroup()which adds people to a cross-site group. There
appear to be no WS methods for adding people to a subsite group.

On the surface, this appears to work fine but the user gets added to the
cross-site group but the invitation email they receive is for the top-level
site and not the subsite we want them to use (i.e. the site that allows
XXXXXCommunityUsers to add to discussion lists, etc).

Here's the code:

UserGroup wsUserGroup = new UserGroup();

//top-level site string urlUserGroupWS =
//subsite string urlUserGroupWS =
string urlUserGroupWS =

wsUserGroup.Url = urlUserGroupWS;
wsUserGroup.Credentials =
crdSuperUsers.GetCredential(uriLists, "Digest");

string sFirstName = "Foo3";
string sLastName = "Foo33";
string sRequestedLoginName = "Foofoo3";
string userName = sFirstName + " " + sLastName + "
(XXXXX Member)";
string userLoginName = "apptix\\" +
string userEmail = "foofoo3@...";
string userNotes = "XXXXX Member since " +

string groupName = "XXXXXCommunityUsers";

//Add the specified user to the specified cross-site
wsUserGroup.AddUserToGroup(groupName, userName,
userLoginName, userEmail, userNotes);

The obvious change to make the code use the WS relative to the XXXXX subsite
url :

string urlUserGroupWS =

instead of the top-level site:

string urlUserGroupWS =

But the web service fails with HTTP 404: Not found. Typing either URL into
IE will display the user friendly version of the WSDL.

Other thoughts/workarounds?



2 Answers Found

Answer #1    Answered By: Hailey Clark     Answered On: Mar 25

The AddUserToRole() web  service will add  a user  to a site  group - here's the
page from the SDK with the code  example:

AddUserToRole Method

The AddUserToRole method  of the Users and Groups service  adds the user to the
specified site group.


roleName A string  that contains the name of the site group.

userName A string that contains the display name of the user.

userLoginName A string that contains the user name (DOMAIN\User_Alias) of the

userEmail A string that contains the e-mail address of the user.

userNotes A string that contains notes for the user.


The AddUserToRole method creates a user if the user does not already exist on
the site.

The following code example adds a user to a specified site group  on the current

[Visual Basic .NET]
Dim usrgrpService As New
Web_Reference_Folder_Name.UserGroup()usrgrpService.Credentials =
roup", "User_Display_Name", _ "DOMAIN\User_Alias", "User_E-mail", "Notes")


Web_Reference_Folder_Name.UserGroup usrgrpService = new
Group", "User_Display_Name", "DOMAIN\\User_Alias", "User_E-mail", "Notes");

Platforms: Microsoft Windows Server 2003

Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/UserGroup.asmx

Answer #2    Answered By: Nisarg Shahane     Answered On: Mar 25

Classic case of rtfm more carefully...........

Didn't find what you were looking for? Find more on WSS UserGroup WS error: Adding a user to a WSS subsite Or get search suggestion and latest updates.