LDAP query test\n";
echo "Connecting ...\n";
$ds=ldap_connect($host, $port);
echo "connect result is " . $ds . "
\n";
if ($ds) {
echo "Binding ...\n";
if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Failed to setup LDAP protocol to 3 - Start TLS not support\n";
exit;
}
echo "Starting TLS...\n";
if (!ldap_start_tls($ds)) {
echo "Cannot start TLS\n";
}
$r=ldap_bind($ds, $dn, $pass);
echo "Bind result is " . $r . "
\n";
echo "Searching for $filter ...";
$sr=ldap_search($ds, $base, $filter);
echo "Search result is " . $sr . "
\n";
echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "
\n";
echo "Getting entries ...
\n"; $info = ldap_get_entries($ds, $sr); echo "Data for " . $info["count"] . " items returned:
\n";
for ($i=0; $i<$info["count"]; $i++) {
echo "dn is: " . $info[$i]["dn"] . "
\n";
//echo "first cn entry is: " . $info[$i]["cn"][0] . "
\n";
//echo "first email entry is: " . $info[$i]["mail"][0] . "