When and why you should use GetInfoEx() in scripts.

Q) First of all, what is the GetInfoEx()?

A) Here is a link to MSDN article that described this method - https://msdn.microsoft.com/ru-RU/library/windows/desktop/aa746350(v=vs.85).aspx


Q) Next, what is the difference between Get() and GetInfoEx()?

A) These methods are not equal. GetInfoEx() doesn't returns any values, it just loads suitable attribute values from directory object to memory cache. And Get() returns attribute value from the memory cache if the value is already in the cache. If the value is not in the cache, Get() (https://msdn.microsoft.com/ru-RU/library/windows/desktop/aa746347(v=vs.85).aspx) loads the value from the directory object and returs it.


Q) What is correct order of use Get() and GetInfoEx()

A) GetInfoEx() first, and then one or more Get().


Q) Can I have an example of use of GetInfoEx() and Get()

A) Here you are.



Set objUser = GetObject("EDMS://CN=John Smith,OU=Sales,DC=mydomain,DC=com")

objUser.GetInfoEx(Array("givenName", "sn"), 0)

strFirstName = objUser.Get("givenName")

strLastName = objUser.Get("sn")


Q) Can GetInfoEx() be used more than once?

A) Yes, sure. But usualy it is used once.


Q) The script above works without GetInfoEx().

A) Yes, it does for the "givenName" and "sn". But it might not work for other attributes.

For example, GetInfoEx() is required for constructed attributed. And GetInfoEx() is always required for virtual attribues.


Q) Does GetInfoEx() affect perfomance?

A) Yes, sure.

When you use GetInfoEx(), it loads a bunch of attributes from directory object at once.

When you don't use GetInfoEx(), each Get() makes a separate loading values from directory object. Multiple calls to directory decrease perfomance.


Q) Should I use GetInfoEx() with the built-in objects DirObj and Request

A) Yes for DirObj. And no for Request.

Request.GetInfoEx() is useless, does nothing.