IADs::GetInfoEx 方法 (iads.h)

IADs::GetInfoEx 方法會將ADSI物件的指定屬性值從基礎目錄存放區載入屬性快取中。

語法

HRESULT GetInfoEx(
  [in] VARIANT vProperties,
  [in] long    lnReserved
);

參數

[in] vProperties

列出要載入 Active Directory 屬性快取之屬性的 Null 終止 Unicode 字串項目陣列。 每個屬性名稱都必須符合這個物件的架構類別定義中的一個。

[in] lnReserved

保留供未來使用。 必須設定為零。

傳回值

這個方法支持標準傳回值,以及下列專案。

如需詳細資訊,請參閱 ADSI 錯誤碼

備註

IADs::GetInfoEx 方法會以目錄存放區中的值覆寫任何先前快取的指定屬性值。 因此,如果在呼叫 IADs::GetInfoEx 之前未叫用 IADs::SetInfo,則對快取所做的任何變更都會遺失。

使用 IADs::GetInfoEx 重新整理 ADSI 物件屬性快取中所選屬性的值。 使用 IADs::GetInfo 重新整理所有屬性值。

針對 ADSI 容器物件, IADs::GetInfoEx 只會快取容器的屬性值,但不會快取子對象的屬性值。

範例

下列程式代碼範例示範如何使用 IADs::GetInfoEx 來取得所選取屬性的值,假設目錄中可以找到所需的屬性值。

Dim x As IADs
On Error GoTo Cleanup

Set x = GetObject("LDAP://CN=JeffSmith,CN=Users,DC=Fabrikam,DC=com")
 
' Retrieve givenName and sn from the underlying directory storage.
' Cache should have givenName and sn values.
x.GetInfoEx Array("givenName", "sn"), 0 
Debug.Print x.Get("givenName")  ' Property is in the cache.
Debug.Print x.Get("sn")         ' Property is in the cache.
 
' If the "homePhone" property is not in the cache (in the next line), 
' GetInfo is called implicitly.
Debug.Print x.Get("homePhone")

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

   Set x = Nothing

下列程式代碼範例示範如何使用 IADs::GetInfoEx 來取得所選取屬性的值,假設目錄中可以找到所需的屬性值。 為了簡潔起見,已省略錯誤檢查。

IADs *pADs = NULL;
VARIANT var;
HRESULT hr = S_OK;
 
hr = ADsGetObject(L"WinNT://somecomputer,computer",
                  IID_IADs,
                  (void**)&pADs);

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

VariantInit(&var);
 
// Get "Owner" and "Division" attribute values.
LPWSTR pszAttrs[] = { L"Owner", L"Division" };
DWORD dwNumber = sizeof( pszAttrs ) /sizeof(LPWSTR);
hr = ADsBuildVarArrayStr( pszAttrs, dwNumber, &var );
hr = pADs->GetInfoEx(var, 0);
VariantClear(&var);
 
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));
VariantClear(&var);

if(pADs)
   pADs->Release();


規格需求

需求
最低支援的用戶端 Windows Vista
最低支援的伺服器 Windows Server 2008
目標平台 Windows
標頭 iads.h
Dll Activeds.dll

另請參閱

IADs

IADs::GetInfo

IADs::SetInfo

屬性快取