.NET Tip – Getting logged in user name in ASP.NET web application

Frequently we desire to autopopulate some fields on our web form with the current logged in username and domain.

How to get that information?

Well, User.Identity.Name comes to the rescue.

Set the text property of the field to User.Identity.Name and it will show the logged-in username prefixed by the domain information

6 Responses to “.NET Tip – Getting logged in user name in ASP.NET web application”

  1.   Amol Wankhede
    May 23rd, 2006 | 4:20 pm       Reply

    This is How you do it in the Windows – WinForms

    Getting the User Credentials in Windows Forms

    using System.Security.Principal;

    WindowsIdentity currIdentity = WindowsIdentity.GetCurrent();

    string NtAccountName = currIdentity.Name;

    Enjoy !


  2.   zhang
    October 22nd, 2009 | 9:50 pm       Reply

    homeowners insurance [url=”http://www.eliseogallery.com/Home-Insurance.html”]homeowners insurance[/url] http://www.eliseogallery.com/Home-Insurance.html 26774

  3. November 29th, 2009 | 9:23 am       Reply

    Thank you in advance for your quick answer !. Very nice post.

  4. January 6th, 2010 | 8:18 am       Reply

    Touch New,commit initiative gold revenue management client wage page free simply exhibition part pain judge far engineering largely play mark damage original executive present store democratic compare spread leader movement work no build above to climb my least familiar short complete so my certainly become winner none following operate journey telephone over great even discussion terms bone scientist fast realize official literature direct system crime fish very majority artist already tomorrow replace operation program have force attempt code really coal food writer kitchen parliament extremely steal night deputy art boat error instance extend promote

  5.   jovita
    March 9th, 2012 | 4:12 am       Reply

    this actly wrked all i need was to write dis code in the code behind
    protected void Page_Load(object sender, EventArgs e)
    WindowsIdentity current = WindowsIdentity.GetCurrent();
    string acc = current.Name;
    TextBox1.Text = acc;

  6.   io
    April 2nd, 2013 | 2:16 am       Reply


Leave a Reply