Directory Services

Deleting an ADAM User

[This documentation is preliminary and subject to change.]

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

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

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

' Delete ADAM User.

Option Explicit

Dim objADAM  ' Binding object.
Dim strPath  ' Binding path.
Dim strUser  ' User to delete.

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

WScript.Echo "Bind to: " & strPath

' Specify User.
strUser = "TestUser"

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:  User=" & strUser

' Delete User.
objADAM.Delete "user", "CN=" & strUser

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