我如何从ASP.NET页当前的loggedIn Windows帐户? [英] How do I get the currently loggedin Windows account from an ASP.NET page?
问题描述
我有一个使用ASP.NET窗体身份验证的ASP.NET 3.5应用程序。我希望能够获得当前登录到计算机的Windows用户名(没有登录到ASP.NET应用程序,但到Windows)时数据的编辑页面。
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.
如果我用 Context.User.Identity.Name.Tostring()
,我得到登录到ASP.NET应用程序的用户名,但我需要的Windows帐户名称。
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()
此外,当我运行从Visual Studio的网站,但在部署后IIS返回 NT AUTHORITY \\ SYSTEM
推荐答案
您必须在您的配置和功放设置认证方式为窗口
;在授权标签也禁止匿名用户。
You have to set authentication mode to Windows
in your configuration & also disable anonymous users in authorization tag.
这篇关于我如何从ASP.NET页当前的loggedIn Windows帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!