Active directory current user in C#

Posted on 2008-11-06
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

Question by:craigdev
    LVL 12

    Accepted Solution

    LVL 12

    Expert Comment

    Or this can also be used.

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

    Author Closing Comment

    LVL 2

    Expert Comment

    it can also be

    System.Environment.UserName; for username

    System.Environment.UserDomainName; for the domain

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Add row in datatable 18 43
    return array from dll 13 21
    How to check if variable integer is empty? 6 37
    C# primary key 9 46
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now