/** * Gets all the email addresses for everyone in the system. * */ function getAllEmailAddrs() { include_once "phpAD.inc.php"; // parse the config file $config = parse_ini_file("Config.ini", 1); // create and connect to the AD $ad = new phpAD($config['Security']['ADServer'], $config['Security']['ADPort']); // validate the user $retVal = $ad->bind($config['Security']['ADServiceName'] . $config['Security']['DomainSuffix'], $config['Security']['ADServicePassword']); // if the user authenticated if ($retVal) { // include the lookup object include_once "Lookups.php"; // get a lookup object $lus = new Lookups(); // get the items for the pull down $lus->getLookupByName("RoleLU"); // get the list $items = $lus->getLookupList(); // init the return value $addrs = ""; // for each AD group foreach ($items as $item) { // get the items for the role $name = "RENCI_" . $lus->getItemNameByID($item->getID()); // get the members of the group $groupMembers = $ad->getGroupMembers($name); // did we get any group members if (!empty($groupMembers)) { // for each member retrieved foreach ($groupMembers as $groupMember) { // get the email address if (isset($groupMember['mail'][0])) { $email = $groupMember['mail'][0]; } else { $email = null; } // did we get an email address back if (!empty($email)) { // force mine to be something else if ($email == "*****@*****.**") { $email = "*****@*****.**"; } // if we dont have this string already, save the email address if (strpos($addrs, $email) === false) { $addrs = $addrs . $email . ","; } } } } } } $addrs = substr($addrs, 0, strlen($addrs) - 1); // return to the caller return $addrs; }