title: Forms Authentication with LDAP "Server is unavailable" error
body: <p>I'm using Active Directory and Forms Authentication to log into a few of our intranet websites. Sometimes when users log in, an exception occurs. I receive an email on all exceptions and so far, this is the only exception that I don't know how to fix. I have researched this on and off for weeks, but I have had no luck in solving this problem. </p>
  
  <p><strong>Source:</strong><br>
  System.DirectoryServices.Protocols</p>
  
  <p><strong>Date and Time:</strong><br>
  01/06/2014 8:37 AM</p>
  
  <p><strong>Message:</strong><br>
  The server is unavailable.</p>
  
  <p><strong>Stack Trace:</strong>  </p>
  
  <blockquote>
    <p>at
    System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential
    newCredential, Boolean needSetCredential)<br>
    at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateCredentials(String
    username, String password)<br>
    at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUserCore(String
    username, String password)<br>
    at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUser(String
    username, String password)<br>
    at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs
    e)<br>
    at System.Web.UI.WebControls.Login.AttemptLogin()<br>
    at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs
    e)<br>
    at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)<br>
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  </p>
  </blockquote>
  
  <p><strong>User:</strong></p>
  
  <p><strong>Browser Information:</strong></p>
  
  <blockquote>
    <p>Browser Capabilities, Type = IE8, Name = IE, Version = 8.0, Major
    Version = 8, Minor Version = 0, Platform = WinXP, Is Beta = False, Is
    Crawler = False, Is AOL = False, Is Win16 = False, Is Win32 = True,
    Supports Frames = True, Supports Tables = True, Supports Cookies =
    True, Supports VBScript = True, Supports JavaScript = 3.0, Supports
    Java Applets = True, Supports ActiveX Controls = True, Supports
    JavaScript Version = 1.5,</p>
  </blockquote>
  
  <p>I am unable to replicate this error on the development server. It's strange, because it will throw the exception, then they can log in just fine after. Some days I don't receive this exception at all, and other days it's off the wall. Could this be a problem with the production server? Possibly a setting is missing or something? I really don't know what's going on with this one. Does anyone have experience with this? </p>
  
  <p>This is how I'm connecting in the <code>web.config</code></p>
  
  <p><strong>Connection string</strong></p>
  
  <pre><code>&lt;add name="ADService" 
       connectionString="LDAP://domain/OU=users,DC=domaincontroller,DC=net" /&gt;
  </code></pre>
  
  <p><strong>Membership provider</strong></p>
  
  <pre><code> &lt;membership defaultProvider="AspNetActiveDirectoryMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;!--Membership provider for Active Directory--&gt;
          &lt;add name="AspNetActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,  System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="ADService" attributeMapUsername="sAMAccountName" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
  </code></pre>
  
  <p>I'm not sure what's going on. Any help is appreciated!</p>
  
  <p>UPDATE: We are currently doing a big release that includes a Single Sign On. We are still using Forms Authentication and Active Directory. We set up a brand new production server. It hasn't went live yet, but some people have access to it. I have already received the same message on this new server. It's Server 2008 R2 Standard. We are using IIS Version 7.5.7600.16385 to be exact. This exception is annoying for me and annoying for the users. It may not happen all the time on the current production but some days it doesn't happen once (not sure if it's because it's a slow day and people aren't using the website) and then some days it happens like crazy and I can get about 15 to 20 of theses exceptions. (if not more)
  I have looked at multiple issues. Others have had a similar problem but theirs occur when they enter the correct username but wrong password. I have tried entering the password in wrong hundreds of times but I could never replicate the problem. </p>