我想使用Windows身份验证获取用户名
实际上我实现了"以不同用户身份登录",单击此按钮时,Windows安全性将出现在那里我们可以提供凭据.
在那个时候,如果我提供一些其他凭证,它只采用当前用户名.如何从Windows安全性获取给定的凭据用户名?
IIS中的主机应用程序然后禁用匿名身份验证并启用了Windows身份验证.
web.config中:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<identity impersonate="true"/>
<authorization>
<allow users="*"/>
<deny users="*"/>
</authorization>
</system.web>
<system.webServer>
<directoryBrowse enabled="true" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
Run Code Online (Sandbox Code Playgroud)
的.cs
在这里,我总是得到默认的用户名
string fullName = Request.ServerVariables["LOGON_USER"];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?提前致谢
c# asp.net authorization windows-authentication windows-security