How do I get the current username in .NET using C#?
The documentation for Environment.UserName seems to be a bit conflicting:
Environment.UserName Property
On the same page it says:
Gets the user name of the person who is currently logged on to the Windows operating system.
AND
displays the user name of the person who started the current thread
If you test Environment.UserName using RunAs, it will give you the RunAs user account name, not the user originally logged on to Windows.