Compartilhar via


UserGroup.AddUserCollectionToRole Method

Adds the collection of users 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/AddUserCollectionToRole", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub AddUserCollectionToRole ( _
    roleName As String, _
    usersInfoXml As XmlNode _
)
'Usage
Dim instance As UserGroup
Dim roleName As String
Dim usersInfoXml As XmlNode

instance.AddUserCollectionToRole(roleName, _
    usersInfoXml)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddUserCollectionToRole", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void AddUserCollectionToRole(
    string roleName,
    XmlNode usersInfoXml
)

Parameters

  • roleName
    Type: System.String

    A string that contains the name of the role definition to add users to.

  • usersInfoXml
    Type: System.Xml.XmlNode

    A System.Xml.XmlNode object that contains information about the users to add in the following form:

    <Users>
       <User LoginName=
          "DOMAIN\User1_Alias" 
          Email="User1_E-mail" 
          Name="User1_Display_Name" 
          Notes="Notes"/>
       <User LoginName=
          "DOMAIN\User2_Alias" 
          Email="User2_E-mail" 
          Name="User2_Display_Name" 
          Notes="Notes"/>
       .
       .
       .
    </Users>
    

Examples

The following code example adds users to a specified role definition on the current Web site. The example assumes the existence of a local XML file that contains the information about the users to add, which is loaded into a System.Xml.XmlDocument object. This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

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

Dim myDocument As New XmlDocument()
myDocument.Load("C:\File_Name.xml")

Dim ndUsers As XmlNode = myDocument.DocumentElement

usrgrpService.AddUserCollectionToRole("Role_Definition", ndUsers)
Web_Reference_Folder_Name.UserGroup usrgrpService = new Web_Reference_Folder_Name.UserGroup();
usrgrpService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlDocument myDocument = new XmlDocument();
myDocument.Load("C:\\File_Name.xml");

XmlNode ndUsers = myDocument.DocumentElement;

usrgrpService.AddUserCollectionToRole("Role_Definition", ndUsers);

See Also

Reference

UserGroup Class

UserGroup Members

UserGroup Web Service