DOC: ADsBuildEnumerator Cannot Be Used with ADSI Collections (201137)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API)
  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q201137

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();
      }
   }
				

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbDSWManage2003Swept kbprb KB201137