DOC: ADsBuildEnumerator Cannot Be Used with ADSI CollectionsID: Q201137
|
The ADSI specification suggests that ADsBuildEnumerator can be used with any of the ADSI enumeratable objects (objects that expose IADsContainer, IADsCollection, or IADsMembers). ADsBuildEnumerator works only with objects that expose an IADsContainer or IADsMembers interface. ADsBuildEnumerator cannot be used with collection objects (objects that expose IADsCollection). The IADsPrintQueueOperations::PrintJobs, IADsFileServiceOperations::Sessions, and IADsFileServiceOperations::Resources methods all return collections.
ADsBuildEnumerator invokes the get__NewEnum() method on the interface pointer it is passed. IADsContainer and IADsMembers have get_NewEnum in the ninth position in their v-tables, so they are compatible for use by ADsBuildEnumerator. IADsCollection has its get_NewEnum method in the eighth positon in its v-table and thus cannot be used with ADsBuildEnumerator.
You can use the following code in place of ADsBuildEnumerator for collection objects:
IADsCollection * pADsCollection;
IEnumVARIANT * pEnumVariant;
{
IUnknown * pUnk = NULL;
hr = pADsCollection->get__NewEnum( &pUnk) ;
if (pUnk){
hr = pUnk->QueryInterface(IID_IEnumVARIANT,
(void **) &pEnumVariant);
pUnk->Release();
}
}
Additional query words: kbADSI
Keywords : kbole kbADSI
Version : WINDOWS:; winnt:
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: February 24, 1999