Directory Services

Binding to an ADAM Instance

[This documentation is preliminary and subject to change.]

To bind to an ADAM object, use a binding string that specifies the path to an ADAM instance and a specified object.

The binding string uses the LDAP provider and requires the following form:

LDAP://host name[:port number][/object name]

In this string:

For more information about LDAP binding strings, see LDAP ADsPath.

The following VBScript code example uses the GetObject function to bind to the application directory partition of an ADAM instance and outputs some of its attributes.

' Bind to ADAM object.

Option Explicit

Dim objADAM	' Object to bind to.
Dim strObject  ' DN of object to bind to.
Dim strPath	' Binding path.
Dim strPort	' Port for ADAM instance.
Dim strServer  ' Server running ADAM instance.

' Choose ADAM server, port, and object for ADAMsPath.

' ADAM server name. Required.
' Change "localhost" to appropriate server.
strServer = "localhost"

' Port for ADAM instance. Optional.
' If absent, default is "389" (non-SSL) or "636" (SSL).
' Change "389" to port for specific instance.
strPort = "389"

' ADAM distinguished name. Optional.
' If absent, default is to instance.
' Change "O=Fabrikam,C=US" to specific object.
strObject = "O=Fabrikam,C=US"

' Construct ADAMsPath binding string.
strPath = "LDAP://"
If strServer <> "" and strServer <> vbNullString Then
	strPath = strPath & strServer
Else
	WScript.Echo "Error: Invalid server specified."
	WScript.Quit
End If
If strPort <> "" and strPort <> vbNullString Then
	strPath = strPath & ":" & strPort
End If
If strObject <> "" and strObject <> vbNullString Then
	strPath = strPath & "/" & strObject
End If
WScript.Echo "Bind to: " & strPath
WScript.Echo

On Error Resume Next

' Get ADAM object.
Set objADAM = GetObject(strPath)

' Output object attributes or error.
If Err.Number = vbEmpty Then
	WScript.Echo "Success: Bind succeeded."
	WScript.Echo "Name:	" & objADAM.Name
	WScript.Echo "Parent:  " & objADAM.Parent
	WScript.Echo "DN:	" & objADAM.distinguishedName
	WScript.Echo "Created: " & objADAM.whenCreated
	WScript.Quit
Else
	WScript.Echo "Error:   Bind failed."
End If