[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Active directory current user in C#

Posted on 2008-11-06
4
Medium Priority
?
1,794 Views
Last Modified: 2011-10-03
How do I read the current logged in active directory user in C#?

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

0
Comment
Question by:craigdev
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
jandromeda earned 2000 total points
ID: 22896511
System.Windows.Forms.SystemInformation.UserName;
0
 
LVL 12

Expert Comment

by:jandromeda
ID: 22896536
Or this can also be used.

System.Security.Principal.WindowsIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();
string userName = id.Name;
0
 
LVL 1

Author Closing Comment

by:craigdev
ID: 31513967
cheers!
0
 
LVL 2

Expert Comment

by:prakash2007
ID: 22896729
it can also be

System.Environment.UserName; for username

System.Environment.UserDomainName; for the domain
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question