我如何从ASP.NET页当前的loggedIn Windows帐户? [英] How do I get the currently loggedin Windows account from an ASP.NET page?

查看:99
本文介绍了我如何从ASP.NET页当前的loggedIn Windows帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆