UserGroup.AddUserToRole Method
Adds the user to the specified role definition.
Namespace: [UserGroup Web service]
Web service reference: http://Site/_vti_bin/UserGroup.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddUserToRole", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub AddUserToRole ( _
roleName As String, _
userName As String, _
userLoginName As String, _
userEmail As String, _
userNotes As String _
)
'Usage
Dim instance As UserGroup
Dim roleName As String
Dim userName As String
Dim userLoginName As String
Dim userEmail As String
Dim userNotes As String
instance.AddUserToRole(roleName, userName, _
userLoginName, userEmail, userNotes)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddUserToRole", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/",
ResponseNamespace = "https://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
Type: System.StringA string that contains the name of the role definition.
userName
Type: System.StringA string that contains the display name of the user.
userLoginName
Type: System.StringA string that contains the user name (DOMAIN\User_Alias) of the user
userEmail
Type: System.StringA string that contains the e-mail address of the user.
userNotes
Type: System.StringA string that contains notes for the user.
Remarks
The AddUserToRole method creates a user if the user does not already exist on the site.
Examples
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");