0

Having issues with trying to get forms authentication working with AD. I've set up everything as follows, but get a 401 error when accessing the Login.aspx page

From my Web.config:

  <connectionStrings>
      <add name="ADService" connectionString="LDAP://dc.domain.com/CN=Users,DC=domain,DC=com"/>
  </connectionStrings>

  <authentication mode="Forms">
      <forms loginUrl="Login.aspx" defaultUrl="Default.aspx" />
  </authentication>

  <authorization>
      <deny users="?" />
      <allow users="*" />
  </authorization>

  <membership defaultProvider="MyADMembershipProvider">
      <providers>
        <clear/>
          <add name="AspNetActiveDirectoryMembershipProvider" 
             type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
             connectionStringName="ADService"
             attributeMapUsername="sAMAccountName"
             connectionUsername="domain\username"
             connectionPassword="password"
             connectionProtection="None" 
             enableSearchMethods="true"/>
      </providers>
  </membership>

This is all running on a Windows 2008 server with IIS7. I have the app pool set to .net version 4.0, integrated. When I test the pass-through authentication, it passes. The only authentication method enabled is Forms Authentication. The site works fine if I switch to Windows Authentication, I just can't seem to get Forms Authentication working. If I enter the domain URL in the browser, it redirects to Login.aspx?ReturnUrl=%2f and displays a 401 error, same thing if I try to navigate directly to login.aspx. I can't seem to find any indication of a problem in any of the server logs. Any ideas on what I might be missing?

user2454029
  • 1
  • 1
  • 1
  • 1
    Did you make sure you enabled anonymous authentication in IIS? Looking through what you posted, it seems entirely correct to me. I wish I had my work laptop with me to compare it to my own. – mason Jun 05 '13 at 04:43
  • Thanks for the advice, turning on anonymous authentication fixed it. I didn't try it earlier, as turning on anonymous authentication seems counterintuitive to actually turning authentication on. – user2454029 Jun 05 '13 at 17:54

0 Answers0