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 はコンテナーのプロパティ値のみをキャッシュしますが、子オブジェクトのプロパティ値はキャッシュしません。

IADs::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::GetInfo の代わりに呼び出す必要があります。 この関数は、指定されたプロパティの以前にキャッシュされた値を上書きします。

次のコード例では、WinNT プロバイダーによって提供されるコンピューター オブジェクトを使用します。 サポートされているプロパティには、 Owner ("Owner")、 OperatingSystem ("Windows NT")、 OperatingSystemVersion ("4.0")、 Division ("Fabrikam")、 ProcessorCount ("Uniprococessor Free")、 Processor ("x86 Family 6 Model 5 Stepping 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")、 Division ("Fabrikam")、 ProcessorCount ("Uniprococessor Free")、 Processor ("x86 Family 6 Model 5 Stepping 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

プロパティ キャッシュ