title: Can't contact LDAP server on ldap_bind($con, $rdn, $pwd)
body: <p>for a while now i'm fiddling around with an LDAP connection to an Active Directory Server for authentication. I tried this the PHP native way and also using Zend Framework. Even though the <code>ldap_connect()</code> works fine, as soon as i bind something, the ldapConnection appears to break down. This is the script i've tried</p>
  
  <pre><code>error_reporting(E_ALL | E_STRICT);
  putenv('LDAPTLS_REQCERT=never');
  
  $ldapcon = ldap_connect("FQSN", 636);
  
  ldap_set_option($ldapcon, LDAP_OPT_PROTOCOL_VERSION, 3);
  ldap_set_option($ldapcon, LDAP_OPT_REFERRALS, 0);
  
  $anon = ldap_bind($ldapcon, "CN=WebTestuserAW,OU=Benutzer,OU=DOM,DC=dom,DC=de", "Sommer2012");
  //also tried: 
  //$anon = ldap_bind($ldapcon, 'WebTestuserAW@dom.de', 'Sommer2012');
  
  echo ldap_error($ldapcon);
  </code></pre>
  
  <p>Using the above i get <strong>Can't contact LDAP server</strong>. Doing a <code>var_dump($ldapcon)</code> returns a resource link. When trying to connect using the Zend Framework approach, the error may have some more hints, since some additional connection parameters are given</p>
  
  <pre><code>2012-11-12T14:37:39+01:00 DEBUG (7): Ldap: 1: host=FQHN,port=636,bindRequiresDn=1,baseDn=OU=Benutzer,OU=DOM,DC=dom,DC=de,accountFilterFormat=(sAMAccountName=%s),useSsl=1,useStartTls=,accountDomainName=dom.de,username=CN=WebTestuserAW,password=*****
  2012-11-12T14:37:39+01:00 DEBUG (7): Ldap: 2: /var/www/html/login/library/Zend/Ldap.php(850): 0x1: Failed to retrieve DN for account: stosic@dvv.de [0x51 (Can't contact LDAP server): ldaps://FGHN:636]
  2012-11-12T14:37:39+01:00 DEBUG (7): Ldap: 3: #0 /var/www/html/login/library/Zend/Auth/Adapter/Ldap.php(316): Zend_Ldap-&gt;bind('username@dom.de', '*****')
  </code></pre>
  
  <p>I seriously just have no clue anymore. I've googled around, played a bit with LDAP-Protocol Versions, played around with the request certificate option, but simply nothing helps. The connection to the server works per se on <code>ldap_connect</code> but as soon as you bind something it doesn't work anymore. This remains true for anonymous binds, too.</p>
  
  <p>At office no one has any clue and neither do i. So if anyone has any suggestions on what i can still try, i'd be very greatful for that! Thanks in advance.</p>
  
  <p>Additional information:</p>
  
  <ul>
  <li>Server LDAP Config:
  <ul>
  <li>LDAP Support enabled</li>
  <li>RCS Version  $Id: ldap.c 299434 2010-05-17 20:09:42Z pajoye $</li>
  <li>Total Links  0/unlimited</li>
  <li>API Version  3001</li>
  <li>Vendor Name  OpenLDAP</li>
  <li>Vendor Version   20343</li>
  <li>SASL Support Enabled</li>
  </ul></li>
  <li>Both ldap:// and ldaps:// has been tested</li>
  <li>ldap_connect() returns a resource link</li>
  <li>ldap_bind() doesn't work, ldap_errno() returns -1 (Can't connect to LDAP Server)</li>
  <li>LDAPTLS_REQCERT and TLS_REQCERT</li>
  </ul>