PHP LDAPS unable to connect to server <pre><code> $username = $_POST['username']; $password = $_POST['password']; $ldaphost = "ldaps://corpldap.xxx.net"; $ldapUsername = "cn=$username,ou=people,dc=xxx,dc=net"; $ldapPassword = "$password"; $ds = ldap_connect($ldaphost,636) or die("\r\nCould not connect to LDAP server\r\n"); echo $ds; //this output 'Resource id #21' ldap_set_option($ds, LDAP_OPT_REFERRALS, 0); if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) { print "Could not set LDAPv3\r\n"; } else { // now we need to bind to the ldap server echo 'success'; //echo success output $bth = ldap_bind($ds) or die("\r\nCould not connect to LDAP server\r\n"); } </code></pre> <p>I get 'Resource id #21 success Could not connect to LDAP server'</p> <p>so ldap_bind is failing</p> <p>stack trace on error log: PHP Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server</p> <p>How can i fix this? Please help.</p> <p>Please note: i also tried $ldaphost = "ldaps://corpldap.xxx.net:636";</p> <p>I also tried echoing php_info() which shows ldap enabled.</p>