Directory Services

Deleting an ADAM Group

[This documentation is preliminary and subject to change.]

To delete an ADAM group, bind to the object that contains the group and delete the group object.

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

The following VBScript code example uses the GetObject function to bind to an organizationalUnit object and uses the Delete method to delete a group object in that organizationalUnit.

' Delete ADAM Group.

Option Explicit

Dim objADAM   ' Binding object.
Dim strGroup  ' Group to delete.
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"

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

WScript.Echo "Delete:  Group=" & strGroup

' Delete Group.
objADAM.Delete "group", "CN=" & strGroup

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