2
votes

I have a question for you.

My goal is to bind a ldap server with php.

  • When I try with a terminal ( bash ) I use:

ldapsearch -H ldaps://[server]:[port] -D [dn] -W

It works well.

  • When I try with a php script

$server = array("ldaps://[server]", "[port]");

$userdn = "[dn]";

$userpw = "[pw]";

$ds = ldap_connect($server[0], $server[1]) or die("ldap server offline");

ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

ldap_bind($ds, $userdn, $userpw);

Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server

I don't understand my mistake. I've search all night long on google.

Q/A

_ I use mamp ( apache )

_ Ldap server pings good, and works with bash.

_ I use a firewall, but it doesnt work without too.

_ all [var] are ok, because in bash it works.

1
you should try using the bit about LDAP_OPT_DIAGNOSTIC_MESSAGE on the ldap_bind man page at php.net to get a more verbose fail message. php.net/manual/en/function.ldap-bind.php - Rooster
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (self signed certificate in certificate chain) - oxmolol
adding TLS_REQCERT allow to ldap.conf and it works! thanks you mate. - oxmolol

1 Answers

1
votes

adding TLS_REQCERT allow to ldap.conf and it works! thanks to @rooster