This topic has not yet been rated - Rate this topic

UserGroup.AddUserToRole Method

Windows SharePoint Services 3
Adds the user to the specified role definition.

Web Service: Users and GroupsWeb Reference: http://<Site>/_vti_bin/usergroup.asmx
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddUserToRole", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public void AddUserToRole (
	string roleName,
	string userName,
	string userLoginName,
	string userEmail,
	string userNotes
)

Parameters

roleName

A string that contains the name of the role definition.

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.

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 role definition on the current site.

Dim usrgrpService As New Web_Reference_Folder_Name.UserGroup()
usrgrpService.Credentials = System.Net.CredentialCache.DefaultCredentials

usrgrpService.AddUserToRole("Role_Definition", "User_Display_Name", _
    "DOMAIN\User_Alias", "User_E-mail", "Notes")

Web_Reference_Folder_Name.UserGroup usrgrpService = new Web_Reference_Folder_Name.UserGroup();
usrgrpService.Credentials= System.Net.CredentialCache.DefaultCredentials;

usrgrpService.AddUserToRole("Role_Definition", "User_Display_Name", 
    "DOMAIN\\User_Alias", "User_E-mail", "Notes");
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.