I have a issue where on my localhost (running on XAMPP) I get the below error "Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server..."
The same code works on the dev server. I have the same code and when i try running the application on my localhost (using XAMPP), it gives me the error.
I tried the below steps I found online:-
-
The xampp\php directory has the following files
- libeay32.dll
- libsasl.dll
- ssleay32.dll
-
I uncommented the ldap extension in the php.ini (xampp\php\php.ini) file to below
extension=php_ldap.dll
Restarted the server
xampp\php directory path is also in system environment variable PATH.
phpinfo shows that LDAP is enabled.
Still, not working. Any idea why from localhost it may not work?
Edit: Adding Code
$hostname = "**********"; $port = 636; $bindDN = "cn=*** ***,ou=binds,dc=***,dc=*******,dc=***"; $bindPassword = "********"; if ($conn = ldap_connect('ldaps://' . $hostname . ':' . $port)) { if (!ldap_bind($conn, $bindDN, $bindPassword)) { return null; } else { return $conn; } }