Platform SDK: Active Directory, ADSI, and Directory Services |
In ADSI, a container object exposes an IADsContainer interface. The IADsContainer interface has the IADsContainer::GetObject method so that you can get bind directly to a child object. The object returned by IADsContainer::GetObject has the same security context as the object on which the method was called. This means if you have pointer to a container object and you know the relative path to a child object, you can avoid having to pass credentials again when binding to the child object. This may be useful when your application is binding using alternate credentials (that is, explicitly specified credentials rather than those of the calling thread).
The IADsContainer::GetObject method enables you to specify the relative RDN path (that is, relative to the current object) and class name (optional) and get back an IDispatch pointer to the specified child object.
For example, if you had an IADsContainer pointer (pCont) to a domainDNS object (DC=Microsoft,DC=com), you could call IADsContainer::GetObject to bind to the Administrator user in the Users container (cn=Administrator,cn=Users,DC=Microsoft,DC=com):
hr = pCont->GetObject(L"user",L"cn=Administrator,cn=Users",&pDisp);
Note The relative path in RDN=value format, and the path is relative to object represented by IADsContainer.