Get a pointer to the System Interface:
hResult = CoCreateInstance(CLSID_System, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER, IID_IADSystem, (void **) &pIADSystem);
Connect to the Domain:
hResult = pIADSystem->Connect(vDomainPath);
vDomainPath is the full path to the domain database (do not enter the domain database name itself, only the path)