使用Windows身份验证的.NET应用程序 应用程序在我的本地解决方案中正常工作。但是当在IIS中托管时,它要求用户访问托管服务器。它不从客户端计算机获取用户凭据。
以下是我的WEb.Config
<authentication mode="Windows">
<!--<forms loginUrl="~/Account/Login.aspx" timeout="2880" />-->
</authentication>
<identity impersonate="false" />
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<httpRuntime maxRequestLength="102400" />
用于获取用户名的ASP代码如下所示
string currentUser = HttpContext.Current.User.Identity.Name.ToLower();
currentUser = currentUser.Replace("kmhp\\", "");
SessionManager.Session.Current.LoggedInUserName = currentUser;
dsValidateLogin = _grantAccessHandler.ValidateLogin(currentUser);
提前致谢
答案 0 :(得分:0)
可能是客户端配置问题。使用Internet Explorer,您必须确保客户端将IIS服务器识别为Intranet区域的一部分。默认情况下,只有Intranet区域允许支持用户凭据。 IE有一些自动检测机制,但并不总是有效。对于Firefox,您需要将IIS服务器主机名添加到about:config中的配置值“network.automatic-ntlm-auth.trusted-uris”。没有它,Firefox也不会将凭据转发到您的服务器。
答案 1 :(得分:-1)
很可能您需要拥有客户端凭据。看看下面的
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport" />
<transport clientCredentialType = "Windows" />
</security>
供参考:HttpBinding