Пример #1
0
/**
 * 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;
}
Пример #2
0
/**
 * Gets the name of a LU item by the ID
 *
 * @param string $luTbl
 * @param int $ID
 */
function displayLUItemNameByID($luTbl, $ID)
{
    // include the lookup object
    include_once "Lookups.php";
    // the name to return
    $name = "";
    // get a lookup object
    $lus = new Lookups();
    // get the items for the pull down
    $retval = $lus->getLookupByName($luTbl);
    // success? get the name
    if ($retval == 0) {
        $name = $lus->getItemNameByID($ID);
    }
    // return to the caller
    return $name;
}
Пример #3
0
            echo "Name:" . $luname . ", ID:" . $obj->ID . "\n";
        }
    }
}
echo "\n Now by name \n";
$itemName = "InventoryStatusLU";
$retval = $lus->getLookupByName($itemName);
// success?
if ($retval == 0) {
    $arr = $lus->getLookupList();
    foreach ($arr as $item) {
        echo "Name:" . $item->Name . ", ID:" . $item->ID . "\n";
    }
}
echo "\n Now by name by ID \n";
$retval = $lus->getItemNameByID(1);
echo "ID: 1, name:" . $retval . "\n";
echo "\n Get the user names\n";
include_once "UserLU.php";
$userlu = new UserLU();
$retval = $userlu->getAllUserNames();
// success?
if ($retval == 0) {
    $arr = $userlu->getUserNameList();
    foreach ($arr as $item) {
        echo "Name:" . $item[0] . "\n";
    }
}
echo "\n Get the user ID/Roles\n";
$retval = $userlu->getUserIDRoles("Phil Owen");
// success?