IADsPropertyList::Item 메서드(iads.h)

IADsPropertyList::Item 메서드는 목록에서 지정된 속성 항목을 검색합니다.

구문

HRESULT Item(
  [in]      VARIANT varIndex,
  [in, out] VARIANT *pVariant
);

매개 변수

[in] varIndex

검색할 속성의 인덱스 또는 이름을 포함하는 VARIANT 입니다.

[in, out] pVariant

호출자가 할당한 VARIANT 변수의 주소입니다. 반환할 때 VARIANT에는 검색된 특성에 대한 IADsPropertyEntry 인터페이스를 구현하는 개체에 대한 IDispatch 포인터가 포함됩니다.

반환 값

이 메서드는 S_OK 포함하여 표준 HRESULT 반환 값을 지원합니다. 자세한 내용 및 기타 반환 값은 ADSI 오류 코드를 참조하세요.

설명

Item 메서드에서 반환된 값이 더 이상 필요하지 않은 경우 VariantClear를 사용하여 pVariant를 지워야 합니다.

예제

다음 코드 예제에서는 Item 메서드를 사용하여 모든 항목을 열거하는 방법을 보여줍니다.

Dim propList As IADsPropertyList
Dim propEntry As IADsPropertyEntry
Dim count As Long

On Error GoTo Cleanup
 
Set propList = GetObject("LDAP://dc02/DC=Fabrikam,DC=com")
 
propList.GetInfo
count = propList.PropertyCount
Debug.Print "No of Property Found: " & count
 
'==== Getting the property list item with Name ==================
Set propEntry = propList.Item("uSNCreated")
Debug.Print propEntry.Name
Debug.Print propEntry.ADsType
 
' to examine property entries by name and type 
For i = 0 To count - 1
    '==== Getting the property list item with Number =============
    Set propEntry = propList.Item(i)
    Debug.Print propEntry.Name
    Debug.Print propEntry.ADsType
Next

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If

    Set propList = Nothing
    Set propEntry = Nothing

다음 코드 예제에서는 IADsPropertyList::Item 메서드를 사용하여 컴퓨터의 Owner 속성을 검색하는 방법을 보여 줍니다. GetPropertyCache 함수 및 코드 예제에 대한 자세한 내용은 IADsPropertyList를 참조하세요.

////////////////////////////////////////
// function:    PropertyItem
//    input:    PropertyList, 
//              name of the item
//   output:    Property entry
//     uses:    IADsPropertyList::Item
////////////////////////////////////////
IADsPropertyEntry *PropertyItem(
         IADsPropertyList *pList,
         LPWSTR item)
{
    IADsPropertyEntry *pEntry;
    VARIANT varEntry, varItem;

    if(!pList || !item)
    {
        _tprintf(TEXT("Invalid parameter..."));
        return NULL;
    }

    VariantInit(&varItem);
    VariantInit(&varEntry);
 
    // get a property entry
    V_BSTR(&varItem)= SysAllocString(item);
    V_VT(&varItem)=VT_BSTR;
    HRESULT hr = pList->Item(varItem ,&varEntry);
    hr = V_DISPATCH(&var)->QueryInterface(
                        IID_IADsPropertyEntry,
                        (void**)&pEntry);
    VariantClear(&varItem);
    VariantClear(&varEntry);
    return pEntry;
}
 
///////////////////////////////////////
// examine a property entry
///////////////////////////////////////
IADsPropertyList *pList; pList=GetPropertyCache(L"WinNT://myComputer,computer");
 
IADsPropertyEntry *pEntry;
pEntry = PropertyItem(pList, L"Owner");

if(pEntry)
{
    HRESULT hr;
    BSTR bstr;
    long ln;

    hr = pEntry->get_Name(&bstr);
    if(SUCCEEDED(hr))
    {
        SysFreeString(bstr);
    }
    printf(" Name : %S\n", bstr);
 
    pEntry->get_ADsType(&ln);
    if(SUCCEEDED(hr))
    {
        printf(" Type : %d\n", ln);
    }
 
    pEntry->get_ControlCode(&ln); 
    if(SUCCEEDED(hr))
    {
        printf(" Code %d\n",ln);
    }
}

요구 사항

   
지원되는 최소 클라이언트 Windows Vista
지원되는 최소 서버 Windows Server 2008
대상 플랫폼 Windows
헤더 iads.h
DLL Activeds.dll

참고 항목

ADSI 오류 코드

IADsPropertyEntry

IADsPropertyList

IADsPropertyList 속성 메서드

IDispatch