GetInfoEx를 사용한 최적화
IADs.GetInfoEx 메서드는 기본 디렉터리 서비스에서 로컬 캐시에 특정 특성 값을 로드하는 데 사용됩니다. 이 메서드는 지정된 특성 값만 로컬 캐시에 로드합니다. IADs.GetInfo 메서드는 모든 특성 값을 로컬 캐시에 로드하는 데 사용됩니다.
IADs.GetInfoEx 메서드는 기본 디렉터리 저장소에서 Active Directory 개체의 속성에 대한 특정 현재 값을 가져오고 캐시된 값을 새로 고칩니다.
그러나 속성 캐시에 값이 이미 있는 경우 해당 특성에 대해 IADs.GetInfoEx를 먼저 호출하지 않고 IADs.Get 또는 IADs.GetEx 메서드를 호출하면 기본 디렉터리에서 가장 최신 값이 아닌 캐시된 값이 검색됩니다. 이로 인해 로컬 캐시가 수정된 경우 업데이트된 특성 값을 덮어쓸 수 있지만 IADs.SetInfo 메서드를 호출하여 기본 디렉터리 서비스에 값이 커밋되지 않았습니다. 캐싱 문제를 방지하기 위해 제안된 방법은 항상 IADs.GetInfo를 호출하기 전에 IADs.SetInfo 를 호출하여 특성 값 변경을 커밋하는 것입니다.
Dim usr As IADs
Dim PropArray As Variant
On Error GoTo Cleanup
' Bind to a specific user object.
Set usr = GetObject("LDAP://CN=Jeff Smith,CN=Users,DC=fabrikam,DC=com")
' The 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 common name is " + usr.Get("cn")
Debug.Print "User's title is " + usr.Get("title")
Debug.Print "User's department is " + usr.Get("department")
' Change two of the attribute values in the local cache.
usr.Put "cn", "Jeff Smith"
usr.Put "title", "Vice President"
usr.Put "department", "Head Office"
Debug.Print "User's common name is " + usr.Get("cn")
Debug.Print "User's title is " + usr.Get("title")
Debug.Print "User's department is " + usr.Get("department")
' Initialize the array of properties to pass to GetInfoEx.
PropArray = Array("department", "title")
' Get the specified attribute values.
usr.GetInfoEx PropArray, 0
' The specific attributes values were overwritten, but the attribute
' value not retrieved has not changed.
Debug.Print "User's common name is " + usr.Get("cn")
Debug.Print "User's title is " + usr.Get("title")
Debug.Print "User's department is " + usr.Get("department")
Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set usr = Nothing
Active Directory 생성 특성 검색
Active Directory에서 생성된 특성의 대부분은 IADs.GetInfo 메서드가 호출될 때 검색되고 캐시됩니다(캐시가 비어 있는 경우 IADs.Get 은 암시적 IADs.GetInfo 호출을 수행함). 그러나 생성된 일부 특성은 자동으로 검색 및 캐시되지 않으므로 IADs.GetInfoEx 메서드를 명시적으로 호출하여 검색해야 합니다. 예를 들어 Active Directory에서 canonicalName 특성은 IADs.GetInfo 메서드가 호출되고 IADs.Get 이 E_ADS_PROPERTY_NOT_FOUND 반환할 때 검색되지 않습니다. canonicalName 특성을 검색하려면 IADs.GetInfoEx 메서드를 호출해야 합니다. 이러한 동일한 생성된 특성은 IADsPropertyList 인터페이스를 사용하여 특성을 열거하는 데도 검색되지 않습니다.
모든 특성 값을 검색하는 방법을 보여 주는 코드 예제 및 자세한 내용은 생성된 특성을 읽기 위한 예제 코드를 참조하세요.