How to obtain user name and domain name in .NET


If you are currently logged in Windows using your domain user name and password and you want to obtain your user name and domain name you can use Environment class as shown below:

Console.WriteLine(Environment.UserDomainName);
Console.WriteLine(Environment.UserName);

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Add Comment