Directory Services


The ADsEnumerateNext function enumerates through a specified number of elements from the current cursor position of the enumerator. When the operation succeeds, the function returns the enumerated set of elements in a variant array. The number of returned elements can be smaller than the specified number.

HRESULT ADsEnumerateNext(
  IEnumVARIANT* pEnumVariant,
  ULONG cElements,
  VARIANT* pvar,
  ULONG* pcElementsFetched


[in] Pointer to the IEnumVARIANT interface on the enumerator object.
[in] Number of elements requested.
[out] Pointer to the array of elements retrieved.
[out] Actual number of elements retrieved, which can be smaller than the number of elements requested.

Return Values

This method supports the standard return values.

For more information about other return values, see ADSI Error Codes.

Return Code Description
S_OK The variant array populated successfully and the number of items returned is the same as those requested (cElement = *pcElementFetched).
S_FALSE The call succeeded, but the number of items returned is less than those requested.


The general process to enumerate objects in a container involves the following:

First, create an enumerator object on that container.

Second, retrieve the IEnumVARIANT interface pointer.

Third, call the ADsEnumerateNext function to return an enumerated set of elements from the enumerator object.

Fourth, call the ADSFreeEnumerator function to free the enumerator object.

For more information and a code example, see the ADsBuildEnumerator topic.


Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Adshlp.h.
Library: Use ActiveDS.lib.

See Also

ADSI Error Codes, ADSI Functions, ADsBuildEnumerator, ADsFreeEnumerator, FreeADsMem, IEnumVARIANT