PHP 8.5.0 Alpha 4 available for testing

Voting

: eight minus one?
(Example: nine)

The Note You're Voting On

php @ fccfurn dot com
22 years ago
To do subtree search from top DN in Active Directory, Make sure you do your ldap_set_option().

<?php
$ldap_host
= "pdc.php.net";
$base_dn = "DC=php,DC=net";
$filter = "(cn=Joe User)";
$ldap_user = "CN=Joe User,OU=Sales,DC=php,DC=net";
$ldap_pass = "pass";
$connect = ldap_connect( $ldap_host, $ldap_port)
or exit(
">>Could not connect to LDAP server<<");
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($connect, $ldap_user, $ldap_pass)
or exit(
">>Could not bind to $ldap_host<<");
$read = ldap_search($connect, $base_dn, $filter)
or exit(
">>Unable to search ldap server<<");
$info = ldap_get_entries($connect, $read);
echo
$info["count"]." entries returned<p>";
$ii=0;
for (
$i=0; $ii<$info[$i]["count"]; $ii++){
$data = $info[$i][$ii];
echo
$data.":&nbsp;&nbsp;".$info[$i][$data][0]."<br>";
}
ldap_close($connect);
?>

<< Back to user notes page

To Top