Need help. LDAP
| From: | ECS) | Date: | Tue, 17 Jul 2001 15:09:56 +0000 |
| Subject: | Need help. LDAP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-58276@lists.php.net to get a copy of this message | ||
In the ldap script below i get the results when i use the decide function at the bottom.
Anyone have a tip on how i can change this so i can push the results into variables instead?
Thanks in advance
//Johan
<?php
function printarray ($what, $display, $info, $i) {
for ($j=0; $j < (count($info[$i]["$what"]) -1); $j++) {
$show = ereg_replace("\\$", "<BR>",
$info[$i]["$what"][$j]);
echo "$display: " . $show . "<br>";
}
}
function decide ($what, $display, $info, $i) {
if (gettype($info[$i]["$what"]) == "array") {
printarray("$what", "$display", $info, $i);
} else {
echo "$display: ". $info[$i]["$what"] . "<br>";
}
}
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("server");
$dn = "o=Name, c=SV";
$filter="(|(uid=$user))";
$justthese = array( "ou", "sn", "givenname", "mail" ,
"cn", "department", "uid");
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
print $info["count"]." entries returned<p>";
for ($i=0; $i<$info["count"]; $i++) {
decide("cn", "I am", $info, $i);
decide("mail", "Email address", $info, $i);
decide("uid", "Signum", $info, $i);
decide("department", "Avdelning", $info, $i);
}
?>