PHPverse 2025

Voting

: six minus five?
(Example: nine)

The Note You're Voting On

IanB
13 years ago
If you're using SSL (e.g. ldaps) and ldap_bind is throwing 'Unable to bind to server:' errors, check that the hostname used in the ldap_connect matches the 'CN' in the SSL certificate on the LDAP server. For example:

<?
ldap_connect('ldaps://ldap01');
// 'ldap01' should match the CN in your LDAP server's SSL cert, otherwise the subsequent ldap_bind() will throw a bind error

?>

You can check your LDAP server's SSL cert using Openssl utility (Linux) - look for the 'Subject' line:

$ openssl x509 -in /etc/pki/tls/certs/ldap01.crt -text -noout
...
Subject: C=XY, ST=My State, L=My City, O=My Org, CN=ldap01/[email protected]
...

I recently applied some updates to my system (now Centos 5.7 and PHP 5.3.6) and started having this issue with PHP scripts that had been fine previously where I was simply using the IP address of the server. Replacing the IP address with the hostname fixed my issue.

<< Back to user notes page

To Top