Platform SDK: Active Directory, ADSI, and Directory Services
Late Binding: What's Happening Under the Hood?
Here is what is happening in the late binding case:
Something binds to an ADSI directory object. For example, LDAP://CN=Jsmith, OU=Sales, DC=Microsoft, DC=COM binds using COM late binding. This causes ADSI to call the QueryInterface method on the IDispatch interface.
ADSI finds an object in the user class and creates an object that supports the appropriate interfaces (such as IADs, IADsUser).
ADSI performs a lookup in the registry and finds extension CLSIDs for user. (Note: ADSI actually caches this information.)
Something makes a call to MyNewMethod. ADSI looks up its dispatch ID and the dispatch IDs for other ADSI extensions. ADSI then finds the extension that serves this call, and calls the IADsExtension interface for that extension.
The extension executes the function.
Now, the client writer invokes YourNewMethod using the IDispatch interface for the current extension. The extension's IDispatch implementation delegates back to the IDispatch for ADSI.
The IDispatch for ADSI again searches for the appropriate extension (or itself), then it calls the appropriate extension using the IADsExtension interface for that extension.