Active directory current user in C#

How do I read the current logged in active directory user in C#?

the VB equivalent would be something like My.User.Name

LVL 1
craigdevAsked:
Who is Participating?
 
jandromedaConnect With a Mentor Commented:
System.Windows.Forms.SystemInformation.UserName;
0
 
jandromedaCommented:
Or this can also be used.

System.Security.Principal.WindowsIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();
string userName = id.Name;
0
 
craigdevAuthor Commented:
cheers!
0
 
prakash2007Commented:
it can also be

System.Environment.UserName; for username

System.Environment.UserDomainName; for the domain
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.