ok so i have a problem: ldap_bind without SSL works just fine but when i switch to SSL it doesn't bind. The simple code im testing this with looks like this


// LDAP variables
$ldaphost = "ldaps://myserver.com";  // your ldap servers
$ldapport = 636;                 // your ldap server's port number

// Connecting to LDAP
$ldapconn = @ldap_connect($ldaphost, $ldapport);
// LDAP settings
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if($ldapconn) {
	echo "LDAP connection works<br />";
else {
	echo "LDAP connection doesn't work<br />";
// LDAP binding anonymously
$ldapbind = ldap_bind($ldapconn);

if ($ldapbind) {
	echo "LDAP bind anonymous successful";
} else {
	echo "LDAP bind anonymous failed";


And after refreshing the page it echoes:

LDAP connection works
LDAP bind anonymous failed

I've been googling like a maniac and everywhere it says that LDAP with SSL should work like that but it doesn't :( It can't be anything with the code? Some serverside issue? And the binding works just fine without SSL...

verify your ldapport number for SSL

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.