";
echo "
";
$ds = ldap_connect("ldaps://ldap-mountain.nems.noaa.gov");
if ($ds) {
$r = ldap_bind($ds, "uid=CMDL.LDAPbind,ou=people,o=noaa.gov", "clb12345"); // authenticated bind
// $r = ldap_bind($ds); // anonymous bind
foreach ($div as $value) {
$sr = ldap_search($ds,"ou=People,o=noaa.gov","(&(ou=ESRL)(ou1=*GMD*)(!(employeetype=Function)))");
$info = ldap_get_entries($ds, $sr);
// save count, usort messes up the count
$count = $info["count"];
usort($info, 'cmp');
// Table header
echo '';
echo "| Name | Email | Phone | Room |
\n";
// after sort first index is 1 not 0!
$tinitial= "";
for ($i=1; $i<=$count; $i++) {
echo " \n";
$name = $info[$i]["cn"][0];
$arr = split (" ", $name);
$c = count($arr);
# If first initial of users last name is different than previous user,
# insert a heading for that letter.
$initial = substr (ucfirst($arr[$c-1]),0,1);
if ($initial != $tinitial) {
echo "
| |
\n";
echo "$initial |
\n";
$tinitial = $initial;
}
# Print out name
echo " " . $name . " | \n";
# email
$address = $info[$i]["mail"][0];
echo " ".$address." | \n";
# Phone number
if (!empty($info[$i]["telephonenumber"][0])) {
echo " ".$info[$i]["telephonenumber"][0]." | \n";
} else {
echo " | \n";
}
# Room number
$room = "";
if (!empty($info[$i]["roomnumber"][0])) {
$room = $info[$i]["roomnumber"][0];
}
echo " ".$room." | \n";
echo " \n\n";
}
echo "
\n";
}
ldap_close($ds);
echo "Miscellaneous Numbers
";
$fcontents = join ('', file ('/wwwext/about/supphone'));
echo $fcontents;
echo 'For a list split up by research group click here.';
echo "
Back to Top\n";
} else {
echo "
Unable to connect to LDAP server
\n";
}
virtual ("/nav/footer.html");
###############################################
//
// mail users name
//
###############################################
function cnentry($entry) {
// $ldapurl = "ldap://dir3.boulder.noaa.gov/uid=".$entry["uid"][0].",ou=People,o=noaa.gov?street,l,st,postalcode,telephonenumber,facsimiletelephonenumber,roomnumber,building,employeetype,title,labeleduri";
# $ldapurl = $entry["labeleduri"][0];
# echo " ".$entry["cn"][0]." | \n";
echo " " . $entry["cn"][0] . " | \n";
}
###############################################
//
// select mail address
//
###############################################
function mailentry($entry) {
$address = $entry["mail"][0];
echo " ".$address." | \n";
}
###############################################
//
// create building/room number string
//
###############################################
function bldgroom($entry) {
# if ($entry["building"]["count"] > 0) {
# $bldg = "bldg ".$entry["building"][0];
# if ($entry["roomnumber"]["count"] > 0) {
if (!empty($entry["roomnumber"][0])) {
$room = $entry["roomnumber"][0];
} else {
$room = "";
}
# } else {
# if ($entry["l"]["count"] > 0) {
# $bldg = $entry["l"][0];
# } else {
$bldg = "";
# }
# }
echo " ".$bldg,$room." | \n";
}
###############################################
# comparison function for sort
###############################################
function cmp($a, $b) {
if ($a["count"] < 1) return 0;
if ($a["sn"][0] == $b["sn"][0]) return 0;
return ($a["sn"][0] > $b["sn"][0])? 1: -1;
}
?>