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

前端 未结 8 1004
余生分开走
余生分开走 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 13:06

    To get the currently logged-in user to Windows in C#, use:

    string Username = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
    

提交回复
热议问题