共用方式為


GetInfo 方法

IADs::GetInfo 方法會從基礎目錄服務將 ADSI 物件的所有屬性值載入本機快取。 IADs::GetInfoEx 方法可用來將特定屬性值載入本機快取。 如需使用 IADs::GetInfoEx 方法的詳細資訊,請參閱使用 GetInfoEx 優化。

當 IADs::Get 或 IADs::Get 或 IADs::GetEx 方法針對特定屬性呼叫,且本機快取中找不到任何值時,ADSI 會進行隱含的 IADs::GetInfo 呼叫。 呼叫 IADs::GetInfo,不會重複隱含呼叫。 不過,如果屬性快取中已經有值,則呼叫 IADs::GetIADs::GetEx 方法時,不需要先呼叫 IADs::GetInfo ,就會擷取快取的值,而不是從基礎目錄擷取最新的值。 如果已修改本機快取,但值尚未認可至基礎目錄服務,且已呼叫 IADs::SetInfo 方法,這可能會導致覆寫更新的屬性值。 若要避免快取問題,請在呼叫 IADs::GetInfo 之前呼叫 IADs::SetInfo 來認可屬性值變更。

Dim usr As IADs

' Bind to a specific user object.
Set usr = GetObject("LDAP://CN=Jeff Smith,CN=Users,DC=fabrikam,DC=com")
 
' This code example assumes that the property description has a single value in the directory.
' Be aware that this will IMPLICITLY call GetInfo because at this point GetInfo
' has not yet been called (implicitly or explicitly) on the usr object.
Debug.Print "User's title is " + usr.Get("title")

' Change the attribute value in the local cache.
usr.Put "title", "Vice President"
Debug.Print "User's title is " + usr.Get("title")

' Call GetInfo, which will overwrite the updated value because SetInfo has not 
' been called.
usr.GetInfo
Debug.Print "User's title is " + usr.Get("title")

某些目錄服務不會傳回物件的所有屬性值,以回應 IADs::GetInfo 呼叫。 在這些情況下,請使用 IADs::GetInfoEx 方法將這些值載入本機快取。