note 31171 added to function.ldap-search
| From: | php at fccfurn dot php dot net | Date: | Fri, 11 Apr 2003 20:35:35 +0000 |
| Subject: | note 31171 added to function.ldap-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46525@lists.php.net to get a copy of this message | ||
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.": ".$info[$i][$data][0]."<br>";
}
ldap_close($connect);
?>
--
http://www.php.net/manual/en/function.ldap-search.php
http://master.php.net/manage/user-notes.php?action=edit+31171
http://master.php.net/manage/user-notes.php?action=delete+31171
http://master.php.net/manage/user-notes.php?action=reject+31171