Getting the windows username in an ASP.NET application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I want to pick up the name of the logged in windows user for my ASP.NET
application.

When I use

System.Environment.UserName

i get ASPNET which is ofcourse not what I want

when I try User.Identity.Name I get an emtry string which is also not what I
want

Is there a way of determining the windows user from and ASP.NET application

Thanks in advance
 
OK solved - User.Identity.name does work so long as I change the directory
security settings on my web server
 
string userName = Request.ServerVariables["AUTH_USER"];

Of course, this only works if Windows Authentication is enabled for your
site (and not anonymous access).

HTH, Jakob.
 
Back
Top