[英]Could not get the Domain User
我有以下代码:
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
部分上一直给我提供了错误的信息
Authentication Type: NTLM Name: SECTOR_A\Administrator IsAnonymous: False IsAuthenticated: True IsGuest: False IsSystem: False Token: 564
我的IIS设置为:
Anonymous Authentication - Disabled ASP.NET Impersonation - Enabled Basic Authentication - Enabled Windows Authentication - Enabled
而且我甚至通过将“ Prompt for user name and password
更改为IE设置,如下所示
======但是======
尽管在打开Web应用程序时在弹出的登录消息中输入了域用户名和密码,但是它没有为我提供正确的Name
部分,应该是SECTOR_HQ\\Jack
。
因此,我想问一下我的代码和配置中是否缺少任何内容。
======添加了Web.config ======
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
======应用程序池信息======
.NET Framework Version: v4.0 Managed Pipeline Mode: Classic Identity: ApplicationPoolIdentity
尝试在配置中添加身份验证部分:
<system.web>
...
<authentication mode="Windows"/>
<identity impersonate="true"/>
...
</system.web>
在这里您可以找到更多详细信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.