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 the ASP.NET application, but into Windows) when data is edited in a page.
If I use Context.User.Identity.Name.Tostring()
, I get the user name logged into the ASP.NET application, but I need the Windows account name.
System.Security.Principal.WindowsIdentity.GetCurrent().Name.Tostring()
Also, it only works when I run the website from Visual Studio, but after deploying to IIS it returns NT AUTHORITYSYSTEM.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…