WindowsIdentity.GetCurrent().Name in ASP.NET

You can use following code, if you want to know the user under which your ASP.NET application is running. 

Add following namespace on top of your web page,
using System.Security.Principal; 

Add following code to Page_Load event,
WindowsIdentity id = WindowsIdentity.GetCurrent();                
Response.Write("Account Name: " + id.Name + "<br>");

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete