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 :
- Install / reinstall php-ldap module.
- Add 1 line of PHP code to set option for LDAP connection.
INSTALL php-ldap MODULE
First thing first you need to check is your php modules, is your php-ldap module already loaded or not? You can check it on your phpinfo();
If there is no php-ldap module installed, please follow these steps carefully to install the php-ldap module :
- Run this script
yum install php-ldap
- After installation success, restart your httpd service, you may use this script
systemctl start httpd
- Add this script below your ldap_connect script :
ldap_set_option($your_ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
Well, I hope my solution above help you out as well.