[SOLUTION] PHP 5.4 error ldap_search(): Search: Can’t contact LDAP server

Lately I got problem with my application which need LDAP for authentication process, in my local server there are no problem. However, once I have uploaded into production server there are some problem appear such as cannot connect to LDAP server (error ldap_search(): Search: Can’t contact LDAP server).

I used Centos 7 for my operating system, PHP 5.4.16 and MySQL 5.7.21. I found some solutions, but I here are the solution worked for me :

  1. Install / reinstall php-ldap module.
  2. Add 1 line of PHP code to set option for LDAP connection.

Continue reading