Beispiel #1
0
function gaasAssignToken_server($msg)
{
    if (!isset($msg["tokenid"])) {
        return false;
    }
    $tokenid = $msg["tokenid"];
    // now, we check the username is in the client gorup
    if (confGetVal("backend") == "AD") {
        if (userInGroup($msg["username"], confGetVal("ad.domain"), confGetVal("ad.user"), confGetVal("ad.pass"), confGetVal("ad.clientdef"))) {
            $myga = new gaasdGA();
            $sql = "select * from hardwaretokens";
            // where tok_name='$tokenid'";
            echo "yes, i am here {$sql}\n";
            $db = getDB();
            $ret = $db->query($sql);
            $tok_key = "";
            $tok_type = "";
            if (!$ret) {
                echo "got a token assignment for an invalid name\n";
                print_r($msg);
                return false;
            } else {
                // we have something
                echo "i am here?\n";
                foreach ($ret as $row) {
                    echo "got a row\n";
                    print_r($row);
                    $tok_key = $row["tok_key"];
                    $tok_type = $row["tok_type"];
                }
            }
            if ($tok_type == "" || $tok_key == "") {
                echo "error in token data from hardware token in DB\n";
            }
            echo "and here too, {$tok_type}, {$tok_key}\n";
            if (!$myga->setUser($msg["username"], $tok_type, "", $tok_key)) {
                print_r($msg);
                echo "errror assigning token?\n";
            }
        } else {
            return false;
        }
    }
    // then we assign to the user
}
$curWeekUpdateString = "";
$nextWeekUpdateString = "";
$restUpdateString = "";
//Array to hold users being added (error-free)
$usersAddedArray = array();
//Array holding users + info to be added to permission table
$insertArray = array();
//Arrays to hold error users
$alreadyInGroupArray = array();
$notInMasterArray = array();
$badEmailUsers = array();
foreach ($fileLines as $user) {
    $netid = getNetId($user);
    if ($netid) {
        //$netid != false
        if (!userInGroup($db, $netid, $groupID)) {
            // user is NOT already in group, continue with addition
            if (userInMasterList($db, $netid)) {
                array_push($usersAddedArray, $netid);
                // add user to permissions table
                // specialHrs = 0 if the group has weekly hours
                $insertString .= "(?,?,?), ";
                array_push($insertArray, $netid, $groupID, $specialHrs);
                if (groupHasCurWeekHours($groupInfo)) {
                    // if group has weekly hours that are currently active,
                    // they should be immediately given to the user
                    $curWeekUpdateString .= "uID = ? OR ";
                }
                if (groupHasNextWeekHours($groupInfo)) {
                    // if group has hours that are active next week,
                    // they should be immediately given to the user
Beispiel #3
0
<?php

require_once "../gaas/lib/globalLib.php";
// function userInGroup($user, $domain, $adlogin, $adpass, $group)
$ret = userInGroup($argv[1], $argv[2], $argv[3], $argv[4], $argv[5]);
if ($ret) {
    echo "true\n";
} else {
    echo "False\n";
}
Beispiel #4
0
 /**
  * Return true if the currently logged in user is a member of the specified group_id.
  * @param int $group_id the group_id to compare to the currently logged in user's group membership.
  */
 static function isLoggedInUserInGroup($group_id)
 {
     global $loggedInUser;
     return userInGroup($loggedInUser->user_id, $group_id);
 }
/**
 * Set user's primary group (by group_id)
 * @param int $user_id the id of the user to update.
 * @param int $group_id the id of the group to set as the primary group.
 * @return boolean true on success false on failure
 */
function updateUserPrimaryGroup($user_id, $group_id)
{
    // This block automatically checks this action against the permissions database before running.
    if (!checkActionPermissionSelf(__FUNCTION__, func_get_args())) {
        addAlert("danger", "Sorry, you do not have permission to access this resource.");
        return false;
    }
    // Check that the group exists, and that the user is a member of it
    if (!groupIdExists($group_id)) {
        addAlert("danger", "I'm sorry, the group id you specified is invalid!");
        return false;
    } else {
        if (!userInGroup($user_id, $group_id)) {
            addAlert("danger", "I'm sorry, the specified user is not a member of the specified group.");
            return false;
        } else {
            if (updateUserField($user_id, 'primary_group_id', $group_id)) {
                addAlert("success", "Primary group for user updated.");
                return true;
            } else {
                return false;
            }
        }
    }
}