System.Environment.UserName internally calls
[DllImport("advapi32.dll", CharSet=CharSet.Auto)] internal static extern bool GetUserName(StringBuilder lpBuffer, ref int nSize);
Each call seems to hit AD, thus network latency and AD query effect speed of execution.
Would you know if there is a better way to retrieve this value?
Something like a cached SID somewhere on the Thread maybe? So I could read UserName & SID and cache these locally (for the time of execution) and only query System.Environment.UserName when I will get new SID (or something along these lines).
Thanks,