Here is the code that simply authenticates and returns the error that I mentioned.
Code:
<Php
echo '<h3> LDAP query test </ h3>';
echo 'Connecting ... <br>';
$ Ds = ldap_connect ("ldaps: / / hostAnnuaire /") / / must be a valid LDAP server!
$ Result = ldap_set_option ($ ds, LDAP_OPT_PROTOCOL_VERSION, 3);
echo "set_option LDAP_OPT_PROTOCOL_VERSION = 2". $ result. "<br>";
if ($ ds) (
echo'Hello... <br> ';
$ Dn = "dn valid";
$ Mdp = "password valid";
echo $ dn. "<br>";
$ R = ldap_bind ($ ds, $ dn, $ password); / / authentication
if ($ r) (
echo "Connection successful LDAP <br>";
Else ()
echo "LDAP Connection Failed:". ldap_error ($ ds). "<br>" / / this is what is the error "can not contact LDAP server
)
echo "Closing connection";
ldap_close ($ ds);
Else ()
echo "<h4> Unable to connect to LDAP server. </ h4> ';
)
?>
Bookmarks