username retrieval

  • Thread starter Thread starter Vincent Haakmat
  • Start date Start date
V

Vincent Haakmat

Hi, I am new to .net and c#
How do I retrieve the windows username?
if possible please provide me some sample code

Regards,

Vincent
 
Vincent,

If you want the name of the currently logged in user, you can use the
static UserName property on the Environment class.

Hope this helps.
 
Thanks for Nicholas's greate response!

Hi Vincent,

Nicholas has provided the best way to get the current username. Besides,
you can also get the username and domain name with the following:

System.Security.Principal.WindowsIdentity.GetCurrent().Name;

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top