<?php
// LDAP variables
//$ldaphost = "host";
$ldaphost = "localhost";
$ldapport = 389;
//$ldap_base_dn = "dc=exemplo,dc=com";
$ldap_base_dn = "dc=zyz,dc=com";
//$ldaprdn = "cn=Manager,$ldap_base_dn";
$ldaprdn = "cn=root,$ldap_base_dn";
$ldappassw = "my_password";
// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport) or die ("Could not connect to $ldaphost");
@ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn,$ldaprdn,$ldappassw);
// verify binding
if (!$ldapbind) {
echo '<script>alert("not connected")</script>';
var_dump($ldapbind);
exit();
}
}
?>
Fail to bind, $ldapbind return bool(false). I have configured phpldapadmin, which is working fine.