title: Unable to establish secure connection with the server , when using LDAP
body: <p>I am working on an asp.net mvc web application, and I have added the following provider to my asp.net <code>web.config</code>:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;membership&gt;
        &lt;providers&gt;
          &lt;add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,Version=4.0.0.0" connectionStringName="TestDomain1ConnectionString" connectionUsername="ad-domainA.intra\it360ad.user" connectionPassword="$$$$$3" /&gt;
  
        &lt;/providers&gt;
      &lt;/membership&gt;
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>&lt;add name="TestDomain1ConnectionString" 
       connectionString="LDAP://10.211.12.30.ad-domainA.intra/CN=Users,DC=ad-domainA,DC=intra" /&gt;
  </code></pre>
  
  <p>but when the users try to access the application and they enter username and password , this will raise the following exception :</p>
  
  <blockquote>
    <p>Unable to establish secure connection with the server </p>
  </blockquote>
  
  <p>So what might be the problem? and also is it right to include my server IP address inside the connection string as I am doing ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I changed my setting to be:</p>
  
  <pre><code> &lt;system.web&gt;
          &lt;trust level="Full" originUrl="" /&gt;
          &lt;membership&gt;
            &lt;providers&gt;
              &lt;add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,Version=4.0.0.0" connectionStringName="TestDomain1ConnectionString" connectionUsername="it360ad.user" connectionPassword="$$$$$" /&gt;
  
            &lt;/providers&gt;
          &lt;/membership&gt;
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>  &lt;add name="TestDomain1ConnectionString" 
         connectionString="LDAP://ad-domainA.intra/OU=TM,DC=ad-doaminA,DC=intra" /&gt;
  </code></pre>
  
  <p>but currently the following check </p>
  
  <pre><code>if(domainProvider.ValidateUser(model.UserName, model.Password)
  </code></pre>
  
  <p>inside the <code>Account</code> controller action method will return </p>
  
  <blockquote>
    <p>The user name or password provided is incorrect</p>
  </blockquote>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  [ValidateAntiForgeryToken]
  public ActionResult Login(LoginModel model, string returnUrl)
  {
     MembershipProvider domainProvider;
  
     domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
  
     // Validate the user with the membership system.
     if (domainProvider.ValidateUser(model.UserName, model.Password))
     {
         //code goes here
     }
     else
     {
         ModelState.AddModelError("", "The user name or password provided is incorrect.");
         return View(model);
     }
  </code></pre>
  
  <p>Can you advice why the validation will always fail ?</p>
  
  <p>Thanks</p>