Platform SDK: Active Directory, ADSI, and Directory Services

Example Code for Binding to an Object Using ADsGetObject

The following code fragment binds to an object with the name Bob in the Microsoft.com domain using ADsGetObject, which uses the caller's security context:

[Visual Basic]
Dim myUser as IADs
Set myUser = GetObject("LDAP://CN=Bob,DC=Microsoft,DC=com")
[C++]
IADs *pObject;
HRESULT hr;
hr = ADsGetObject(L"LDAP://CN=Bob,DC=Microsoft,DC=com", 
        IID_IADs,
        (void**) &pObject);