Directory Services

IADsPropertyList::Next

The IADsPropertyList::Next method gets the next item in the property list. The returned item is a Property Entry object.

HRESULT Next( 
  VARIANT* pVariant
);

Parameters

pVariant
[out] Address of a caller-allocated variable that contains the value of the next item in the property list. The return value of VT_DISPATCH refers to an IDispatch interface pointer to an object implementing the IADsPropertyEntry interface.

Return Values

This method supports the standard HRESULT values, including S_OK if the item is obtained. When the last item in the list is returned, the return value that is returned will differ depending on which provider is used. The following codes are used to indicate that the last item in the list was obtained:

Return Code Description
E_FAIL Used for the LDAP provider.
E_ADS_PROPERTY_NOT_FOUND Used for the WinNT provider.
E_FAIL Used for the NDS provider.
E_ADS_BAD_PARAMETER Used for the NWCOMPAT provider.

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

Remarks

You must clear pVariant using VariantClear when the value returned by the Next method is no longer required.

Example Code [Visual Basic]

The following code example shows how to walk through a property list using the Next method.

Dim propList As IADsPropertyList
Dim v as Variant
Dim propVal As IADsPropertyValue
 
On Error Resume Next
 
Set propList = GetObject("LDAP://dc01/DC=Fabrikam,DC=com")
 
propList.GetInfo
Set v = propList.Next()
While (Not (IsNull(v)) And Err.Number = 0)
	Set propEnty = v
	Debug.Print v.Name
	Debug.Print v.AdsType

	Set v = propList.Next
Wend

Example Code [C++]

The following C++ code example shows how to work the IADsPropertyList::Next method.

////////////////////////////////////
// Function used to retrieve an entry using the 
// IADsPropertyList::Next method.
 
//	 name: GetNextEntry
//	input: IADsPropertyList*
//   return: IADsPropertyEntry
//	 uses: IADsPropertyList::Next
/////////////////////////////////////////////////////////
IADsPropertyEntry* GetNextEntry(IADsPropertyList* pList)
{
	VARIANT var;
	VariantInit(&var);
	IADsPropertyEntry *pEntry;

	if(!pList)
	{
		_tprintf("An error has occurred.");
		return NULL;
}
 
	HRESULT hr = pList->Next(&var);
	hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
										 (void**)&pEntry);
	VariantClear(&var);
	return pEntry;
}

Requirements

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 Iads.h.

See Also

ADSI Error Codes, IADsPropertyEntry, IADsPropertyList, IADsPropertyList Property Methods, IDispatch