It can also be a timing issue. THat is why it is important to optimize protocols and provider order. Some people have been known to add a SLEEP in the script to give it time. When KiX encounters a macro or function that calls for a round trip to the DC, it does a pre-fetch of several attributes. You might want to force a call very early in the script so that it may be available later.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.