Platform SDK: Active Directory, ADSI, and 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
The item was successfully obtained.
S_FALSE
The current item is the last one in the list. No item was obtained.

For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic code snippet 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=Microsoft,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 snippet shows how to work the IADsPropertyList::Next method.

////////////////////////////////////
// function 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;
 
    HRESULT hr = pList->Next(&var);
    hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
                                         (void**)&pEntry);
    VariantClear(&var);
    return pEntry;
}
 
IADsPropertyList *GetPropertyCache(LPWSTR);
 
void TestPropertyNext()
{
    IADsPropertyList *pList;
    pList=GetPropertyCache(L"WinNT://myComputer,computer");
 
    IADsPropertyEntry *pEntry=GetPropertynext(&pList);
 
    printf("Printing from TestPropertyNext()…\n");
    BSTR bstr;
    long ln;
 
    hr = pEntry->get_Name(&bstr);
    printf("   Name: %S\n",bstr);
    SysFreeString(bstr);
 
    hr = pEntry->get_ADsType(&ln); 
    printf("   Type: %d\n",ln);
 
    hr = pEntry->get_ControlCode(&ln);
    printf("   Code: %d\n",ln);
}

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

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