PHP 8.5.0 Alpha 4 available for testing

Voting

: four minus three?
(Example: nine)

The Note You're Voting On

asohn at aircanopy dot net
17 years ago
Some code I put together. Maybe yall can benefit from it.

<?php
function search_results($info) {
foreach (
$info as $inf) {
if (
is_array($inf)) {
foreach (
$inf as $key => $in) {
if ((
count($inf[$key]) - 1) > 0) {
if (
is_array($in)) {
unset(
$inf[$key]["count"]);
}
$results[$key] = $inf[$key];
}
}
}
}
$results["dn"] = explode(',', $info[0]["dn"]);
return
$results;
}

$user = "asohn";

$ds = ldap_connect("ldap://DOMAIN.net");
if (
$ds) {
$r = ldap_bind($ds);
$sr = ldap_search($ds, "ou=customers,dc=DOMAIN,dc=net", "uid=".$user);
$info = ldap_get_entries($ds, $sr);

echo
$info["count"]." Search Result(s) for \"".$user."\"\n";

$results = search_results($info);
foreach (
$results as $key => $result) {
echo
" ".$key."\n";
if (
is_array($result)){
foreach(
$result as $res){
echo
" ".$res."\n";
}
}
}
ldap_close($ds);
}
?>

<< Back to user notes page

To Top