我有以下代码:
protected void Page_Load(object sender, EventArgs e)
{
string infors = "";
System.Security.Principal.WindowsIdentity usr = System.Security.Principal.WindowsIdentity.GetCurrent();
infors += "Authentication Type: " + usr.AuthenticationType + "<br>";
infors += "Name: " + usr.Name + "<br>";
infors += "IsAnonymous: " + usr.IsAnonymous + "<br>";
infors += "IsAuthenticated: " + usr.IsAuthenticated + "<br>";
infors += "IsGuest: " + usr.IsGuest + "<br>";
infors += "IsSystem: " + usr.IsSystem + "<br>";
infors += "Token: " + usr.Token.ToString() + "<br>";
Label1.Text = infors;
}
Name
但是,它一直在给我错误的信息
身份验证类型:NTLM 名称:SECTOR_A\管理员 匿名:错误 IsAuthenticated: 真 IsGuest:错误 是系统:假 代币:564
我的 IIS 设置为:
匿名身份验证 - 已禁用 ASP.NET 模拟 - 已启用 基本身份验证 - 已启用 Windows 身份验证 - 已启用
我什至通过设置来更改 IE 设置,Prompt for user name and password
如下所示
====== 但是 ======
虽然我在打开 Web 应用程序时在弹出的登录消息中输入了域用户名和密码,但它没有给我正确的Name
部分,应该是SECTOR_HQ\Jack
.
所以我想问一下我的代码和配置中是否缺少任何东西。
====== 添加了 Web.config ======
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
====== 应用程序池信息 ======
.NET 框架版本:v4.0 托管管道模式:经典 身份:ApplicationPoolIdentity