Groups | Blog | Home
all groups > c# > august 2004 >

c# : Get the windows login name


HK guy
8/5/2004 11:41:01 PM
How to use C# to get the login name of the windows?
Irfan
8/5/2004 11:50:23 PM
Hi,
you could use the following code for the same.

System.Security.Principal.WindowsPrincipal wp = new
System.Security.Principal.WindowsPrincipal
(System.Security.Principal.WindowsIdentity.GetCurrent());

MessageBox.Show(wp.Identity.Name);

Here the messagebox displays the domain name alongwith the
user logged in(the UseriD). Using the ID, you could
validate the user.

Jason Newell
8/6/2004 1:48:54 AM
System.Environment.UserName


[quoted text, click to view]

AddThis Social Bookmark Button