Get Windows Login name
We can get the windows login in 2 ways,
1) Using Environment
str = System.Environment.UserDomainName + "\" + System.Environment.UserNamestr;
str will Contain the Login name with the domain name.
2) Using the System.Security
Using System.Security.Principal;
WindowsPrincipal wp = New WindowsPrincipal(WindowsIdentity.GetCurrent());
MessageBox.Show("Your login id:" + wp.Identity.Name);
3) Using SystemInformation
System.Windows.Forms.SystemInformation.UserName;
0 Comments:
Post a Comment
<< Home