Directory Services

Getting a List of Specified ADAM Objects

[This documentation is preliminary and subject to change.]

To search ADAM for specific objects, specify a filter that limits the type of objects selected.

For more information about filtering in a query, see Creating a Query Filter.

The following VBScript code example uses the GetObject function to bind to an organizationalUnit object, uses the Filter property to select group objects, and outputs the name of each group present in the organizationalUnit.

' Enumerate filtered ADAM objects.

Option Explicit

Dim objADAM	' Binding object.
Dim objFilter  ' Filter object.
Dim strFilter  ' Filter to select objects.
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 filtered object type.
strFilter = "group"

WScript.Echo "Filter:  " & strFilter

On Error Resume Next

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

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

' Enumerate filtered objects.
objADAM.Filter = Array(strFilter)
For Each objFilter in objADAM
	WScript.Echo objFilter.Name
Next

' Output success or error.
If Err.Number <> vbEmpty Then
	WScript.Echo "Error:   Filtered enumeration failed."
Else
	WScript.Echo "Success: Filtered enumeration complete."
End If