Directory Services

Creating an ADAM Group

[This documentation is preliminary and subject to change.]

To create an ADAM group, bind to the object that will contain the user, create a group object, set its properties, and save the object to the directory store.

You can delete the object you create with the following code example by Deleting an ADAM Group.

The following VBScript code example uses the GetObject function to bind to an organizationalUnit object, uses the Create method to create a group object in that organizationalUnit, and sets properties for group.

' Create ADAM Group.

Option Explicit

Dim objADAM		 ' Binding object.
Dim objGroup		' Group object.
Dim strDescription  ' Description of group.
Dim strDisplayName  ' Display name of group.
Dim strGroup		' Group.
Dim strPath		 ' Binding path.

' Construct ADAMsPath binding string.
' Change "localhost" to appropriate server.
' Change "389" to port for appropriate instance.
' Change "OU=TestOU,O=Fabrikam,C=US" to appropriate object.
strPath = "LDAP://localhost:389/OU=TestOU,O=Fabrikam,C=US"

WScript.Echo "Bind to: " & strPath

' Specify Group.
strGroup = "TestGroup"
strDisplayName = "Test Group"
strDescription = "ADAM Test Group"

WScript.Echo "Create:  " & strGroup
WScript.Echo "		 " & strDisplayName
WScript.Echo "		 " & strDescription

On Error Resume Next

' Bind to the object.
Set objADAM = GetObject(strPath)

' Output error if the bind operation fails.
If Err.Number <> vbEmpty Then
	WScript.Echo "Error:   Bind failed."
	WScript.Quit
End If

' Create Group.
Set objGroup = objADAM.Create("group", "CN=" & strGroup)
objGroup.Put "displayName", strDisplayName
objGroup.Put "description", strDescription
objGroup.SetInfo

' Output success or error.
If Err.Number <> vbEmpty Then
	WScript.Echo "Error: Create failed."
Else
	WScript.Echo "Success: Group created."
End If