We've finally set-up our server to accept ldap SSL connections thanks to another question answered by a helpful member.

Our problem now is that when attempting to bind to ldap using the below simple PHP script, we constantly fail. Binding using ldap instead of ldaps works just fine using the script so I know the ldap is enabled. The catcher is that while using LDP.exe, we can successfully connect and bind to ldap on port 636 using a secure connection.

The script we are failing with is below:

$ldap = ldap_connect("ldaps://localhost");

if($bind = ldap_bind($ldap, $username,$password ))
echo "logged in";
    echo "fail";
    echo "<br/>done";

We've also attempted inputting the username as "user@domain" or "domain/user" with no success. It seems I'm forever having LDAP/Cert questions. Our environment is Server 2008.

3 Answers 3


Finally found another piece of the solution while using PHP 7.x. Hope this helps someone else.

Thanks to reddit user gripejones here: https://www.reddit.com/r/PHPhelp/comments/3tykpc/php_7_and_ldap/

PHP 7 requires an environment variable (LDAPCONF) set to the location of your config file. It used to be that you could put the config file either in this folder C:\openldap\sysconf\ldap.conf or in C:\ldap.conf.

You don't need to copy the dll files as mentioned in step 2 here: http://greg.cathell.net/php_ldap_ssl.html

Make sure the reference to the ldap server is in the form ldaps://servername and that the server name is the same as the server name in the certificate (If it is xyzzy.company.com, then you need to use ldaps://xyzzy.company.com, do not use ldaps://xyzzy).

No need to include the port unless you are using a nonstandard ssl port.


Change the URL to include the port used for SSL, for example ldaps://localhost:636 (assuming 636 is the port upon which the LDAP server listens for secure client connections).

  • We receive the same result using ldaps://locahost:636. 636 is definitely the port that is open on our ldap server.
    – Sean
    Nov 5, 2012 at 16:24
  • Hi Terry, do you by any chance know what else I can possibly do to resolve the issue?
    – Sean
    Nov 7, 2012 at 12:58

Followed: http://greg.cathell.net/php_ldap_ssl.html

Looks like steps #3, #5-7 needed be complete in Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.