【发布时间】:2013-03-23 23:28:55
【问题描述】:
我有一个关于 IIS 7 身份验证的问题。我希望我的应用程序显示 Windows 用户名。可能吗?如果是我怎么能做到这一点?
<identity impersonate="false"/>
<authorization>
<deny users="?"/>
</authorization>
<authentication mode="Windows"/>
显示我使用的用户名:
Label1.Text = (Environment.UserName);
Label2.Text = (Page.User.Identity.Name);
Label3.Text =(Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1));
Label4.Text = (System.Security.Principal.WindowsIdentity.GetCurrent().Name);
Label5.Text = (System.Web.HttpContext.Current.User.Identity.Name);
Label6.Text = Request.ServerVariables["LOGON_USER"];
以上都行不通...
我的 IIS 设置: 启用 Asp.net 模拟,启用 Windows 身份验证...
有人看到问题了吗?
非常感谢和问候!
已编辑:我忘了补充一点,我不希望用户被提示输入任何凭据。我希望用户名自动显示。
【问题讨论】:
-
如果改为设置
会怎样? -
无济于事...感谢您的回复 -
您是否禁用了匿名身份验证?用户只有在无法匿名进入时才会受到挑战
标签: c# asp.net authentication iis