Last week I encountered the following error message: Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in C:\xamppNew\htdocs\index.php on line 11
To create a AD user you must to connect to the LDAP via securely (SSL). Usually you can achieve this in PHP by connecting through LDAP like this: ldap_connect("ldaps://<host>", 636); , watch the ‘s’ at the end of LDAP. This indicates you want to connect through SSL. After binding ( ldap_bind($connection, $user, $password); ) I received the error message above.
I was 100% sure the LDAP server was not the cause of this, because it was working when I did the same in C#. After doing a lot of research on the internet I finally found a (working) solution. I tested this solution on Windows and Ubuntu and they are working fine.
Windows:
- Create the follwing directory, usually this directory doesn’t exist (yet): “C:\OpenLDAP\sysconf”
- In “C:\OpenLDAP\sysconf” create a file called “ldap.conf”.
- Add “TLS_REQCERT never” (without quotes) at the end of the file you just created.
- Restart your Apache server.
Ubuntu:
- Navigate to “/etc/ldap/”
- Open the file “ldap.conf”
- Add “TLS_REQCERT never” (without quotes) at the end of the file.
- Restart your Apache server.
According to the manual, “TLS_REQCERT never” prevents the server from requesting and/or checking any server certificate.
Happy coding!
You saved me! I had the very same problem with a LDAPs. Hartelijk bedankt!
I’m glad I could help.
Thanks!
I was searching by days in the web, but you have the solutions!
Atte. Alfroy_GT