4.1.2 Binding to a Known Object

An ADsPath string that identifies a known object can be transformed into an interface on an Active Directory object using the binding functions GetObject() in Visual Basic or ADsGetObject() in C/C++.

The following example assumes a namespace named "WinNT", and a user object that is uniquely identified by the provider specific path "MSFT\Users\John".

Example 1: Binding to a Known Object (Visual Basic)

Dim MyObject as IADs

Set MyObject = GetObject("WinNT://MSFT/Users/John")

Example 1: Binding to a Known Object (C/C++)

IADs *pMyObject;

ADsGetObject(TEXT("WinNT://MSFT/Users/John"),

IID_IADs,

(void**)&pMyObject);

GetObject() is a Visual Basic function that is used to instantiate Automation objects. ADsGetObject() is a helper function supplied by Active Directory. For more information about the Active Directory helper functions, see Appendix B. The actual binding process is discussed in detail in Appendix C.