This topic has not yet been rated - Rate this topic

UserGroup.AddUserCollectionToGroup Method

SharePoint 2010

Adds the collection of users to the specified group.

Namespace:  [UserGroup Web service]
Web service reference: http://Site/_vti_bin/UserGroup.asmx
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddUserCollectionToGroup", RequestNamespace = "http://schemas.microsoft.com/sharepoint/soap/directory/", 
	ResponseNamespace = "http://schemas.microsoft.com/sharepoint/soap/directory/", 
	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void AddUserCollectionToGroup(
	string groupName,
	XmlNode usersInfoXml
)

Parameters

groupName
Type: System.String
The name of the group to add users to.
usersInfoXml
Type: System.Xml.XmlNode
A System.Xml.XmlNode object that contains information about the users 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>

The following code example adds a collection of users to a group. The example assumes the existence of a local XML file that contains information about the users, 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.

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

XmlDocument myDocument = new XmlDocument();
myDocument.Load("URL");

XmlNode ndUsers = myDocument.DocumentElement;

usrgrpService.AddUserCollectionToGroup("Group_Name", ndUsers);
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ