Directory Services

Binding

Binding is an element common to all ADSI applications. To use ADSI methods and properties, bind an object to a computer, a domain controller, a user, or some other object in a directory structure. When bound, you may read or change the object properties and invoke methods relevant to that object type.

The following code example illustrates ADSI binding.

Set myObj = GetObject("WinNT://Domain/Machine/Object,Class")

The argument to GetObject is called an ADsPath or binding string. An ADSI binding string consists of:

Note  GetObject is used for binding when you are already authenticated in the domain. If you are not authenticated in the domain then you must bind using OpenDSObject.

Provider

The provider part of the string indicates what type of namespace to bind to. ADSI includes four different providers.

Provider Purpose
WinNT: For communicating with Windows NT 4.0 Primary Domain Controllers (PDCs) and Backup Domain Controllers (BDCs).
LDAP: For communicating with LDAP servers, including Exchange 5.x directory and Windows 2000 Active Directory.
NDS: For communicating with Novell Directory Services servers.
NWCOMPAT: For communicating with Novell NetWare servers.

The provider is case sensitive; WinNT is different from WINNT; spell the name with the appropriate case. This tutorial focuses primarily on the WinNT provider.

If you supply only the provider in the binding string, for example, "WinNT:", ADSI binds to the root of the provider namespace and allow access to all the objects in the enterprise.

Path

Usually, you will want to bind to a more specific object than the entire namespace. The path allows you to do this.

To bind to the root of a specific domain, use the following format.

Set myObj = GetObject("WinNT://MyDomain")

You can also bind to a specific computer without specifying a domain name. If the computer you bind to is not a domain controller, the provider will bind to the local computer accounts. The following code example shows the syntax.

Set myObj = GetObject("WinNT://Server01,computer")

Binding to objects below the level of computer is also possible. The following code example shows the syntax.

Set myObj = GetObject("WinNT://MyDomain/dc01/Bob,user")

This will bind to the user Bob on the domain controller dc01 in the domain MyDomain.

The part of the binding string after the comma is called the class specifier, and it is optional. Class specifiers are useful to prevent ambiguity between object names, and can help reduce the time required to bind to an object. In the last example, specifying the user ensures that if there is also a computer named Bob in the dc01 domain controller, the provider will bind to the user Bob instead of to the computer.