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

IADs::GetInfo 메서드는 기본 디렉터리 저장소에서 이 ADSI 개체의 지원되는 속성의 속성 캐시 값으로 로드됩니다.

구문

HRESULT GetInfo();

반환 값

이 메서드는 표준 반환 값과 다음을 지원합니다.

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

설명

IADs::GetInfo 함수는 속성 캐시를 초기화하거나 새로 고치기 위해 호출됩니다. 이는 기본 디렉터리 저장소에서 지원되는 속성의 속성 값을 가져오는 것과 비슷합니다.

초기화되지 않은 속성 캐시가 반드시 비어 있는 것은 아닙니다. IADs::P ut 또는 IADs::P utEx를 호출하여 지원되는 속성에 대한 속성 캐시에 값을 배치하고 캐시는 초기화되지 않은 상태로 유지됩니다.

IADs::GetInfo에 대한 명시적 호출은 전체 속성 캐시를 로드하거나 다시 로드하여 캐시된 모든 속성 값을 덮어씁니다. 그러나 암시적 호출은 캐시에 설정되지 않은 속성만 로드합니다. ADSI 개체의 최신 속성 값을 검색하려면 항상 IADs::GetInfo 를 명시적으로 호출합니다.

IADs::GetInfo에 대한 명시적 호출은 속성 캐시의 모든 값을 덮어쓰기 때문에 IADs::SetInfo가 IADs::GetInfo 이전에 호출되지 않은 경우 캐시에 대한 모든 변경 내용이 손실됩니다.

ADSI 컨테이너 개체의 경우 IADs::GetInfo 는 컨테이너의 속성 값만 캐시하지만 자식 개체의 속성 값은 캐시하지 않습니다.

IAD::Get 및 IADs::GetInfo 메서드 간의 차이점을 강조하는 것이 중요합니다. 전자는 속성 캐시에서 지정된 속성의 값을 반환하는 반면, 후자는 지원되는 모든 속성 값을 기본 디렉터리 저장소의 속성 캐시에 로드합니다.

다음 코드 예제에서는 IADs::Get 및 IADs::GetInfo 메서드 간의 차이점을 보여 줍니다.

Set x = GetObject("LDAP://CN=Administrator,CN=Users,DC=Fabrikam,DC=com")
                                     ' The first IADs::Get calls
                                     ' GetInfo implicitly.
Debug.Print x.Get("homePhone")       ' Assume value is '999-9999'. 
x.Put "homePhone", "868-4449"        ' Put with no commit(SetInfo)
Debug.Print x.Get("homePhone")       ' Value='868-4449' from the cache.
x.GetInfo                            ' Refresh the cache, get the data 
                                     ' from the directory.
Debug.Print x.Get("homePhone")       ' Value will be '999-9999'.

성능 향상을 위해 명시적으로 IADs::GetInfoEx 를 호출하여 특정 속성을 새로 고칩니다. 또한 개체의 작업 속성 값에 액세스해야 하는 경우 IADs::GetInfoEx 대신 IADs::GetInfoEx를 호출해야 합니다. 이 함수는 지정된 속성의 이전에 캐시된 값을 덮어씁니다.

예제

다음 코드 예제에서는 WinNT 공급자가 제공하는 컴퓨터 개체를 사용합니다. 지원되는 속성에는 Owner ("Owner"), OperatingSystem ("Windows NT"), OperatingSystemVersion ("4.0"), 나누기 ("Fabrikam"), ProcessorCount ("Uniprococessor Free"), 프로세서 ("x86 제품군 6 모델 5 단계 1")가 포함됩니다. 기본값은 괄호로 표시됩니다.

Dim pList As IADsPropertyList
Dim pEntry As IADsPropertyEntry
Dim pValue As IADsPropertyValue

On Error GoTo Cleanup
 
Set pList = GetObject("WinNT://localhost,computer")
 
' pList now represents an uninitialized empty property cache.
pList.Put "Owner", "JeffSmith"  ' Property cache remains uninitialized,
                               ' but with one property value.
count = pList.PropertyCount  ' count = 1.
MsgBox "Number of property found in the property cache: " & count
 
v = pList.Get("Division")   ' pList.GetInfo is called implicitly
ShowPropertyCache           ' This will display "JeffSmith" for Owner,
                            ' "Fabrikam" for Division, "Windows NT" for
                            ' OperatingSystem, and so on.
 
pList.GetInfo                ' Refreshes the entire cache, overwriting 
                             ' "JeffSmith" for the Owner property.
ShowPropertyCache            ' This will display "Owner" for Owner,
                             ' "Fabrikam" for Division, "Windows NT" for
                             ' OperatingSystem, and so on.

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set pList = Nothing
    Set pEntry = Nothing
    Set pValue = Nothing

 
Private Sub ShowPropertyCache()
    For I = 0 To pList.PropertyCount-1
       Set pEntry = pList.Item(I)
       Debug.Print pEntry.Name
       For Each v In pEntry.Values
           Set pValue = v
           Debug.Print "   " & pvalue.CaseIgnoreString
       Next
    Next
End Sub

다음 코드 예제는 IADs::GetInfo 메서드의 효과를 보여 주는 클라이언트 쪽 스크립트입니다. 지원되는 속성에는 Owner ("Owner"), OperatingSystem ("Windows NT"), OperatingSystemVersion ("4.0"), 나누기 ("Fabrikam"), ProcessorCount ("Uniprococessor Free"), 프로세서 ("x86 제품군 6 모델 5 단계 1")가 포함됩니다. 기본값은 괄호로 표시됩니다.

<html>
<body>
 <table>
    <tr>
       <td>Owner:</td>
       <td><input type=text name=txtOwner></td>
    </tr>
    <tr>
       <td>Operating System:</td>
       <td><input type=text name=txtOS></td>
    </tr>
    <tr>
       <td>Operating System Version:</td>
       <td><input type=text name=txtOSV></td>
    </tr>
    <tr>
       <td>Division:</td>
       <td><input type=text name=txtDiv></td>
    </tr>
 </table>

 <input type=button onClick = "showGetInfo()">
</body>

<script language="vbscript">
Dim pList 

sub showGetInfo()
  Set oFac = CreateObject("ADsFactory")
  path = "WinNT://Fabrikam"
  ADS_SECURE_AUTH = 1
  On Error Resume Next

' Browser security requires enabled/Prompt for "Initialize and 
' script ActiveX Controls not marked as safe"
  Set pList=oFac.OpenDSObject(path,vbNullString,vbNullString,ADS_SECURE_AUTH)
   
  ' pList now represents an uninitialized empty property cache
  pList.Put "Owner" "JeffSmith"  ' Property cache remain uninitialized
                                 ' but with one property value.
   
  v = pList.Get("Division")   ' pList.GetInfo is called implicitly
  ShowPropertyCache           ' This will display "JeffSmith" for Owner,
                              ' "Fabrikam" for Division, "Windows NT"
                              ' for OperatingSystem, and so on.
 
  pList.GetInfo                ' Refreshes entire cache, overwriting 
                               ' "JeffSmith" for the Owner property.
  ShowPropertyCache            ' This will display "Owner" for Owner,
                               ' "Fabrikam" for Division, "Windows NT"
                               ' for OperatingSystem, and so on.
end sub

sub ShowPropertyCache()
  txtOwner.value = pList.Get("Owner")
  txtDiv.value = pList.Get("Division")
  txtOS.Value = pList.Get("OperatingSystem")
  txtOSV.value = pList.Get("OperatingSystemVersion")
end sub
</script>

</html>

다음 코드 예제에서는 Get 및 GetInfo의 효과를 강조 표시합니다. 간단히 하기 위해 오류 검사는 생략됩니다.

IADs *pADs;
IADsPropertyList *pList;
BSTR bstr;
VARIANT var;
HRESULT hr;
 
hr = ADsGetObject(L"WinNT://somecomputer,computer",
                  IID_IADsPropertyList,
                  (void**)&pList);

if(!(hr==S_OK)){return hr;}

VariantInit(&var);
 
// Get the number of property entries, should be zero.
long pCount;      
hr = pList->get_PropertyCount(&pCount);
printf("    prop count = %d\n",pCount);     // 0 for empty cache.
 
hr = pList->QueryInterface(IID_IADs, (void**)&pADs);
 
 
// Set "Owner=JeffSmith" in the property cache.
V_BSTR(&var) = SysAllocString(L"JeffSmith");
V_VT(&var) = VT_BSTR;
hr = pADs->Put(CComBSTR("Owner"), var);
VariantClear(&var);
 
// This time the number of property entries should read one (1).
hr = pList->get_PropertyCount(&pCount);
printf("    prop count = %d\n",pCount);    // 1 for what was set.
 
// The following Get invokes GetInfo implicitly, but 
// the cache (that is, "Owner=JeffSmith") remains intact.
hr = pADs->Get(CComBSTR("Division"), &var);  
printf("    division   = %S\n", V_BSTR(&var));
VariantClear(&var);
 
hr = pADs->Get(CComBSTR("Owner"), &var);
printf("    owner      = %S\n", V_BSTR(&var));  // Owner = JeffSmith
VariantClear(&var);
 
// The following GetInfo call refreshes the entire prop cache.
// Now Owner is no longer "JeffSmith", but the value stored in the
// persistent store, for example, "BenSmith".
hr = pADs->GetInfo();
 
hr = pADs->Get(CComBSTR("Owner"), &var);
printf("    owner      = %S\n", V_BSTR(&var));  // Owner = BenSmith
VariantClear(&var);
 
// ...

if(pADs)
   pADs->Release();

if(pList)
   pList->Release();

요구 사항

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

참고 항목

IAD

IADs::Get

IADs::GetEx

IADs::GetInfoEx

속성 캐시