DOC: ADsBuildEnumerator Cannot Be Used with ADSI Collections

ID: Q201137


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API)
  • Microsoft Win32 Software Development Kit (SDK)
    on the following platforms: Alpha, NT, Win95, x86


SUMMARY

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.


MORE INFORMATION

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 25, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.