title: LDAPS not connecting with PHP
body: <p>I'm having issues using Windows to connect to a secure LDAP server, and I see the same thing everywhere online with no solution thats worked so far.</p>
  
  <p>I have tried using both IIS and WAMPSERVER. I have put libeay32.dll and ssleay32.dll in my SYSTEM32 directory and enabled the LDAP extension.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>putenv('LDAPTLS_REQCERT=never');
  ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
  $resource = ldap_connect("ldaps://{redacted}/", 636) or die ("Could not connect.");
  ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)
  $bound = ldap_bind($resource, "{redacted}\ldap", "****");
  
  echo ldap_error($resource);
  </code></pre>
  
  <p>I get <code>Can't contact LDAP server</code> from ldap_error and the PHP warning <code>Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in C:\wamp\www\ldapTest.php</code></p>
  
  <p>The server I am attempting to connect to is running Active Directory and I have confirmed that I can connect by using other LDAP tools. I know this server has an issue with it's certificate - the LDAP tool I am using says <code>The server you are trying to connect to is using a certificate which could not be verified! - Issuer certificate not found</code></p>
  
  <p>My suspicion is that the bad certificate is causing the bind issue which is why I've tried the LDAPTLS_REQCERT=never.</p>