Logo 
Search:

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: 1856

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 =
"https://sharepointcentral.sharepointsite.com/_vti_bin/UserGroup.asmx";
//subsite string urlUserGroupWS =
"https://sharepointcentral.sharepointsite.com/XXXX/_vti_bin/UserGroup.asmx";
string urlUserGroupWS =
"https://sharepointcentral.sharepointsite.com/_vti_bin/UserGroup.asmx";

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\\" +
sRequestedLoginName;
string userEmail = "foofoo3@...";
string userNotes = "XXXXX Member since " +
dtNow.ToShortDateString();

string groupName = "XXXXXCommunityUsers";

//Add the specified user to the specified cross-site
group
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 =
"https://sharepointcentral.sharepointsite.com/XXXXX/_vti_bin/UserGroup.asmx"

instead of the top-level site:

string urlUserGroupWS =
"https://sharepointcentral.sharepointsite.com/_vti_bin/UserGroup.asmx";

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?

Share: 

 

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.

Parameters

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
user.

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

userNotes A string that contains notes for the user.

Remarks

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

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

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

[C#]

Web_Reference_Folder_Name.UserGroup usrgrpService = new
Web_Reference_Folder_Name.UserGroup();usrgrpService.Credentials=
System.Net.CredentialCache.DefaultCredentials;usrgrpService.AddUserToRole("Site_\
Group", "User_Display_Name", "DOMAIN\\User_Alias", "User_E-mail", "Notes");

Requirements
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.




Tagged: