简体   繁体   中英

windows authentication in ASP.NET application not working properly after hosting in IIS

NET Application using windows Authentication the application is working fine in my Local solution. but when hosted in IIS it is asking for the users access to The hosted server. it is not fetching user credentials from the client Machine.

Below is my 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" />

And ASP code behind to get user name is as below

string currentUser = HttpContext.Current.User.Identity.Name.ToLower();
                currentUser = currentUser.Replace("kmhp\\", "");
                SessionManager.Session.Current.LoggedInUserName = currentUser;
                dsValidateLogin = _grantAccessHandler.ValidateLogin(currentUser);

Thanks in advance

that could be a client configuration issue. With Internet Explorer you have to make sure the client recognizes the IIS server as part of your intranet zone. By default only the intranet zone allows fowarding the user credentials. IE has some automatic detection mechanism but that doesn't always work. For Firefox you need to add your IIS server hostname to the configuration value "network.automatic-ntlm-auth.trusted-uris" in about:config. Without that, Firefox will also not forward the credentials to your server.

Most probably you need to have client credential. Take a look below

<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport" />
   <transport clientCredentialType = "Windows" />
</security>

For reference: HttpBinding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM