IADs::GetEx 메서드(iads.h)

IADs::GetEx 메서드는 속성 캐시에서 지정된 특성의 속성 값을 검색합니다. 반환된 속성 값은 단일 값 또는 다중값일 수 있습니다. IADs::Get 메서드와 달리 속성 값은 VARIANT의 변형 배열 또는 이진 데이터에 대한 바이트의 변형 배열로 반환됩니다. 그런 다음 단일 값 속성이 단일 요소의 배열로 표시됩니다.

구문

HRESULT GetEx(
  [in]  BSTR    bstrName,
  [out] VARIANT *pvProp
);

매개 변수

[in] bstrName

속성 이름을 지정하는 BSTR 을 포함합니다.

[out] pvProp

속성의 값 또는 값을 받는 VARIANT 에 대한 포인터입니다.

반환 값

이 메서드는 표준 반환 값과 다음 목록에 나열된 반환 값을 지원합니다.

자세한 내용은 ADSI 오류 코드를 참조하세요.

설명

IADs::GetIADs::GetEx 메서드는 단일 값 속성 값에 대해 다른 변형 구조를 반환합니다. 속성이 문자열인 경우 IADs::Get 은 문자열의 변형(VT_BSTR)을 반환하는 반면 , IADs::GetEx 는 단일 요소가 있는 VARIANT 형식 문자열의 변형 배열을 반환합니다. 따라서 다중값 특성이 단일 값 또는 여러 값을 반환할지 확실하지 않은 경우 IADs::GetEx를 사용합니다. 결과의 데이터 구조의 유효성을 검사할 필요가 없으므로 단일 값 또는 여러 값이 있는지 확실하지 않은 경우 IADs::GetEx 를 사용하여 속성을 검색할 수 있습니다. 다음 목록에서는 두 메서드를 비교합니다.

IADs::Get version IADs::GetEx 버전
Dim x as IADs

otherNumbers = x.Get("otherHomePhone")
If VarType(otherNumbers) = vbString Then
  Debug.Print otherNumbers
Else
  For Each homeNum In otherNumbers
    Debug.Print homeNum
  Next
End If
Dim x as IADs

otherNumbers = x.GetEx("otherHomePhone")
For Each homeNum In otherNumbers
  Debug.Print homeNum
Next
 

IADs::Get 메서드와 마찬가지로 IADs::GetEx는 초기화되지 않은 속성 캐시에 대해 IADs::GetInfo를 암시적으로 호출합니다. IAD::GetInfo에 대한 암시적 및 명시적 호출에 대한 자세한 내용은 IADs::GetInfo를 참조하세요.

예제

다음 코드 예제에서는 IADs::GetEx 를 사용하여 개체 속성을 검색하는 방법을 보여 줍니다.

Dim x As IADs
On Error GoTo ErrTest:
 
Set x = GetObject("LDAP://CN=Administrator,CN=Users,DC=Fabrikam,DC=com")
 
' Single value property.
Debug.Print "Home Phone Number is: " 
phoneNumber = x.GetEx(""homePhone")
For Each homeNum in phoneNumber
    Debug.Print homeNum
Next
 
' Multiple value property.
Debug.Print "Other Phone Numbers are: "
otherNumbers = x.GetEx("otherHomePhone")
For Each homeNum In otherNumbers
    Debug.Print homeNum
Next
Exit Sub
 
ErrTest:
    Debug.Print Hex(Err.Number)
    Set x = Nothing

다음 코드 예제에서는 IADs::Get 메서드를 사용하여 개체의 선택적 속성 값을 검색하는 방법을 보여 줍니다.

<HTML>
<head><title></title></head>

<body>
<%
Dim x 

On Error Resume Next
Set x = GetObject("WinNT://Fabrikam/Administrator")
Response.Write "Object Name: " & x.Name & "<br>"
Response.Write "Object Class: " & x.Class & "<br>"
 
' Get the optional property values for this object.
Set cls = GetObject(x.Schema)
For Each op In cls.OptionalProperties
   vals = obj.GetEx(op)
   if err.Number = 0 then
       Response.Write "Optional Property: & op & "=" 
       for each v in vals 
          Response.Write v & " "
       next
       Response.Write "<br>"
   end if
Next
%>

</body>
</html>

다음 코드 예제에서는 IADs::GetEx를 사용하여 "homePhone" 속성 값을 검색합니다.

IADs *pADs = NULL;
 
hr = ADsGetObject(L"LDAP://CN=Administrator,CN=Users,DC=Fabrikam,DC=Com", IID_IADs, (void**) &pADs );
if ( !SUCCEEDED(hr) ) { return hr;}
 
hr = pADs->GetEx(CComBSTR("homePhone"), &var);
if ( SUCCEEDED(hr) )
{
    LONG lstart, lend;
    SAFEARRAY *sa = V_ARRAY( &var );
    VARIANT varItem;
 
    // Get the lower and upper bound.
    hr = SafeArrayGetLBound( sa, 1, &lstart );
    hr = SafeArrayGetUBound( sa, 1, &lend );
 
    // Iterate and print the content.
    VariantInit(&varItem);
    printf("Getting Home Phone using IADs::Get.\n");
    for ( long idx=lstart; idx <= lend; idx++ )
    {
        hr = SafeArrayGetElement( sa, &idx, &varItem );
        printf("%S ", V_BSTR(&varItem));
        VariantClear(&varItem);
    }
    printf("\n");
 
    VariantClear(&var);
}
 
// Cleanup.
if ( pADs )
{
    pADs->Release();
}

요구 사항

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

참고 항목

IAD

IADs::Get

IADs::GetInfo

IADs::P ut

IADs::P utEx

속성 캐시 인터페이스