I can connect to a domain’s Active Directory using ADsGetObject:
IADs domain;
ADsGetObject("LDAP://fabrikam.com", IADs, domain);
But how can I query active directory when I need to specify the credentials (i.e. the interactive user does not have permissions to query active directory, or is not a valid user in that domain)?
Have you try to bind With ADsOpenObject and IADsOpenDSObject::OpenDSObject.