Microsoft KB Archive/201137

{|
 * width="100%"|

DOC: ADsBuildEnumerator Cannot Be Used with ADSI Collections

 * }

Q201137

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API)
 * Microsoft Win32 Software Development Kit (SDK)

-

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-&gt;get__NewEnum( &pUnk) ; if (pUnk){ hr = pUnk-&gt;QueryInterface(IID_IEnumVARIANT,                                  (void **) &pEnumVariant); pUnk-&gt;Release; }  } Additional query words: kbADSI

Keywords : kbole kbADSI

Issue type : kbprb

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWin32API