How do I get the currently loggedin Windows account from an ASP.NET page?

前端 未结 8 1009
余生分开走
余生分开走 2020-12-01 12:25

I have an ASP.NET 3.5 application that uses ASP.NET forms authentication. I want to be able to get the Windows user name currently logged into the computer (NOT logged into

8条回答
  •  臣服心动
    2020-12-01 12:57

    string strName = HttpContext.Current.User.Identity.Name.ToString();
    

    like you wanted it to do was correct, but you need to set up the webserver first, referring to How to Get Window NT Logged User Name Using ASP.NET (first steps setting up a web server).

提交回复
热议问题