note 35019 added to function.ldap-search
| From: | me at gavinadams dot org | Date: | Fri, 15 Aug 2003 18:38:59 +0000 |
| Subject: | note 35019 added to function.ldap-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54228@lists.php.net to get a copy of this message | ||
Minor clarification on AD LDAP searchs. Small typo in previous example, and does not display
multiple values per attribute. Here's the for loop to enumerate all entries, attributes, and
values:
$bind = ldap_bind($connect) // asume anon connect or add user/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<br>";
// $i = entries
// $ii = attributes for entry
// $iii = values per attribute
for ($i = 0; $i<$info["count"]; $i++) {
for ($ii=0; $ii<$info[$i]["count"]; $ii++){
$data = $info[$i][$ii];
for ($iii=0; $iii<$info[$i][$data]["count"]; $iii++) {
echo $data.": ".$info[$i][$data][$iii]."<br>";
}
}
echo "<p>"; // separate entries
----
Manual Page -- http://www.php.net/manual/en/function.ldap-search.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35019
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35019&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35019&report=yes