Share via


UserGroup.AddGroup Method

Adds a group to the current site collection.

Web Service: Users and GroupsWeb Reference: http://<Site>/_vti_bin/usergroup.asmx

Syntax

<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddGroup", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/directory/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Sub AddGroup ( _
    groupName As String, _
    ownerIdentifier As String, _
    ownerType As String, _
    defaultUserLoginName As String, _
    description As String _
)

Dim instance As UserGroup
Dim groupName As String
Dim ownerIdentifier As String
Dim ownerType As String
Dim defaultUserLoginName As String
Dim description As String

instance.AddGroup(groupName, ownerIdentifier, ownerType, defaultUserLoginName, description)
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddGroup", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public void AddGroup (
    string groupName,
    string ownerIdentifier,
    string ownerType,
    string defaultUserLoginName,
    string description
)

Parameters

  • groupName
    A string that contains the name of the new group.
  • ownerIdentifier
    A string that contains the user name (DOMAIN\User_Alias) of the owner for the group.
  • ownerType
    A string that specifies the type of owner, which can be either user or group.
  • defaultUserLoginName
    A string that contains the user name (DOMAIN\User_Alias) of the default user for the group.
  • description
    A string that contains a description of the group.

Remarks

Adding a group to a Web site also adds the group to the parent site collection.

Example

The following code example adds a new group to the current site collection.

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

usrgrpService.AddGroup("Group_Name", "DOMAIN\Owner_Alias", "user", "DOMAIN\User_Alias", "Description")
Web_Reference_Folder_Name.UserGroup usrgrpService = new Web_Reference_Folder_Name.UserGroup();
usrgrpService.Credentials= System.Net.CredentialCache.DefaultCredentials;

usrgrpService.AddGroup("Group_Name", "DOMAIN\\Owner_Alias", "user", "DOMAIN\\User_Alias", "Description");

See Also

Reference

UserGroup Class
UserGroup Members
Users and Groups Web Service