GetInfo 方法
IADs::GetInfo 方法从基础目录服务将 ADSI 对象的所有属性值加载到本地缓存中。 IADs::GetInfoEx 方法用于将特定属性值载入本地缓存中。 有关使用 IADs::GetInfoEx 方法的更多信息,请参阅使用 GetInfoEx 进行优化。
当为特定属性调用 IADs::Get 或 IADs::GetEx 方法并且在本地缓存中找不到值时,ADSI 将进行隐式 IADs::GetInfo 调用。 调用 IADs::GetInfo 时,不会重复隐式调用。 但是,如果属性缓存中已经存在某个值,那么在调用 IADs::Get 或 IADs::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 方法将这些值加载到本地缓存中。