function updateLDAPUser($authtype, $userid) { global $authMechs; $esc_userid = mysql_real_escape_string($userid); $userData = getLDAPUserData($authtype, $userid); if (is_null($userData)) { return NULL; } $affilid = $authMechs[$authtype]['affiliationid']; $now = unixToDatetime(time()); // select desired data from db $qbase = "SELECT i.name AS IMtype, " . "u.IMid AS IMid, " . "u.affiliationid, " . "af.name AS affiliation, " . "af.shibonly, " . "u.emailnotices, " . "u.preferredname AS preferredname, " . "u.uid AS uid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "COALESCE(u.rdpport, 3389) AS rdpport, " . "u.showallgroups " . "FROM user u, " . "IMtype i, " . "affiliation af " . "WHERE u.IMtypeid = i.id AND " . "af.id = {$affilid} AND "; if (array_key_exists('numericid', $userData) && is_numeric($userData['numericid'])) { $query = $qbase . "u.uid = {$userData['numericid']}"; } else { $query = $qbase . "u.unityid = '{$esc_userid}' AND " . "u.affiliationid = {$affilid}"; } $qh = doQuery($query, 255); $updateuid = 0; # check to see if there is a matching entry where uid is NULL but unityid and affiliationid match if (array_key_exists('numericid', $userData) && is_numeric($userData['numericid']) && !mysql_num_rows($qh)) { $updateuid = 1; $query = $qbase . "u.unityid = '{$esc_userid}' AND " . "u.affiliationid = {$affilid}"; $qh = doQuery($query, 255); } // if get a row // update db // update results from select if ($user = mysql_fetch_assoc($qh)) { $user["unityid"] = $userid; $user["firstname"] = $userData['first']; $user["lastname"] = $userData["last"]; $user["email"] = $userData["email"]; $user["lastupdated"] = $now; $query = "UPDATE user " . "SET unityid = '{$esc_userid}', " . "firstname = '{$userData['first']}', " . "lastname = '{$userData['last']}', " . "email = '{$userData['email']}', "; if ($updateuid) { $query .= "uid = {$userData['numericid']}, "; } $query .= "lastupdated = '{$now}' "; if (array_key_exists('numericid', $userData) && is_numeric($userData['numericid']) && !$updateuid) { $query .= "WHERE uid = {$userData['numericid']}"; } else { $query .= "WHERE unityid = '{$esc_userid}' AND " . "affiliationid = {$affilid}"; } doQuery($query, 256, 'vcl', 1); } else { // call addLDAPUser $id = addLDAPUser($authtype, $userid); $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.uid AS uid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "COALESCE(u.rdpport, 3389) AS rdpport, " . "u.showallgroups, " . "u.usepublickeys, " . "u.sshpublickeys, " . "u.lastupdated AS lastupdated " . "FROM user u, " . "IMtype i, " . "affiliation af " . "WHERE u.IMtypeid = i.id AND " . "u.affiliationid = af.id AND " . "u.id = {$id}"; $qh = doQuery($query, 101); if (!($user = mysql_fetch_assoc($qh))) { return NULL; } $user['sshpublickeys'] = htmlspecialchars($user['sshpublickeys']); } // TODO handle generic updating of groups switch (getAffiliationName($affilid)) { case 'EXAMPLE1': updateEXAMPLE1Groups($user); break; default: //TODO possibly add to a default group } $user["groups"] = getUsersGroups($user["id"], 1); $user["groupperms"] = getUsersGroupPerms(array_keys($user['groups'])); $user["privileges"] = getOverallUserPrivs($user["id"]); $user['login'] = $user['unityid']; return $user; }
function getUserInfo($id) { $affilid = DEFAULT_AFFILID; if (!is_numeric($id)) { getAffilidAndLogin($id, $affilid); } $user = array(); $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "u.emailnotices, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.id AS id, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "u.showallgroups, " . "u.lastupdated AS lastupdated, " . "af.shibonly " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND "; if (is_numeric($id)) { $query .= "u.id = {$id}"; } else { $query .= "u.unityid = '{$id}' AND af.id = {$affilid}"; } $qh = doQuery($query, "105"); if ($user = mysql_fetch_assoc($qh)) { if (datetimeToUnix($user["lastupdated"]) > time() - SECINDAY || $user['unityid'] == 'vclreload' || $user['affiliation'] == 'Local' || $user['shibonly']) { # get user's groups $user["groups"] = getUsersGroups($user["id"], 1); checkExpiredDemoUser($user['id'], $user['groups']); # get user's privileges $user["privileges"] = getOverallUserPrivs($user["id"]); if (preg_match('/@/', $user['unityid'])) { $tmparr = explode('@', $user['unityid']); $user['login'] = $tmparr[0]; } else { $user['login'] = $user['unityid']; } return $user; } } if (is_numeric($id)) { return updateUserData($id, "numeric"); } return updateUserData($id, "loginid", $affilid); }
function updateLDAPUser($authtype, $userid) { global $authMechs; $userData = getLDAPUserData($authtype, $userid); if (is_null($userData)) { return NULL; } $affilid = $authMechs[$authtype]['affiliationid']; $now = unixToDatetime(time()); // select desired data from db $query = "SELECT i.name AS IMtype, " . "u.IMid AS IMid, " . "u.affiliationid, " . "af.name AS affiliation, " . "af.shibonly, " . "u.emailnotices, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.preferredname AS preferredname, " . "u.uid AS uid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "u.showallgroups " . "FROM user u, " . "IMtype i, " . "adminlevel a, " . "affiliation af " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "af.id = {$affilid} AND "; if (array_key_exists('numericid', $userData) && is_numeric($userData['numericid'])) { $query .= "u.uid = " . $userData["numericid"]; } else { $query .= "u.unityid = '{$userid}' AND " . "u.affiliationid = {$affilid}"; } $qh = doQuery($query, 255); // if get a row // update db // update results from select if ($user = mysql_fetch_assoc($qh)) { $user["unityid"] = $userid; $user["firstname"] = $userData['first']; $user["lastname"] = $userData["last"]; $user["email"] = $userData["email"]; $user["lastupdated"] = $now; $query = "UPDATE user " . "SET unityid = '{$userid}', " . "firstname = '{$userData['first']}', " . "lastname = '{$userData['last']}', " . "email = '{$userData['email']}', " . "lastupdated = '{$now}' "; if (array_key_exists('numericid', $userData) && is_numeric($userData['numericid'])) { $query .= "WHERE uid = " . $userData["numericid"]; } else { $query .= "WHERE unityid = '{$userid}' AND " . "affiliationid = {$affilid}"; } doQuery($query, 256, 'vcl', 1); } else { // call addLDAPUser $id = addLDAPUser($authtype, $userid); $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.uid AS uid, " . "u.id AS id, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "u.showallgroups, " . "u.lastupdated AS lastupdated " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND " . "u.id = {$id}"; $qh = doQuery($query, 101); if (!($user = mysql_fetch_assoc($qh))) { return NULL; } } // TODO handle generic updating of groups switch (getAffiliationName($affilid)) { case 'EXAMPLE1': updateEXAMPLE1Groups($user); break; default: //TODO possibly add to a default group } $user["groups"] = getUsersGroups($user["id"], 1); $user["privileges"] = getOverallUserPrivs($user["id"]); $user['login'] = $user['unityid']; return $user; }
function getUserInfo($id, $noupdate = 0, $numeric = 0) { $affilid = DEFAULT_AFFILID; if (!$numeric) { $rc = getAffilidAndLogin($id, $affilid); if ($rc == -1) { return NULL; } } $user = array(); $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "u.emailnotices, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "COALESCE(u.rdpport, 3389) AS rdpport, " . "u.showallgroups, " . "u.lastupdated AS lastupdated, " . "u.usepublickeys, " . "u.sshpublickeys, " . "af.shibonly " . "FROM user u, " . "IMtype i, " . "affiliation af " . "WHERE u.IMtypeid = i.id AND " . "u.affiliationid = af.id AND "; if ($numeric) { $query .= "u.id = {$id}"; } else { $query .= "u.unityid = '{$id}' AND af.id = {$affilid}"; } $qh = doQuery($query, "105"); if ($user = mysql_fetch_assoc($qh)) { $user['sshpublickeys'] = htmlspecialchars($user['sshpublickeys']); if (datetimeToUnix($user["lastupdated"]) > time() - SECINDAY || $user['unityid'] == 'vclreload' || $user['affiliation'] == 'Local' || $user['shibonly'] || $noupdate) { # get user's groups $user["groups"] = getUsersGroups($user["id"], 1); $user["groupperms"] = getUsersGroupPerms(array_keys($user['groups'])); checkExpiredDemoUser($user['id'], $user['groups']); # get user's privileges $user["privileges"] = getOverallUserPrivs($user["id"]); if (preg_match('/@/', $user['unityid'])) { $tmparr = explode('@', $user['unityid']); $user['login'] = $tmparr[0]; } else { $user['login'] = $user['unityid']; } $blockids = getBlockAllocationIDs($user); $user['memberCurrentBlock'] = count($blockids); return $user; } } if ($numeric) { $user = updateUserData($id, "numeric"); } else { $user = updateUserData($id, "loginid", $affilid); } if (!is_null($user)) { $blockids = getBlockAllocationIDs($user); $user['memberCurrentBlock'] = count($blockids); } return $user; }
function updateITECSUser($userid) { global $ENABLE_ITECSAUTH; if (!$ENABLE_ITECSAUTH) { return NULL; } $query = "SELECT id AS uid, " . "first, " . "last, " . "email, " . "created " . "FROM user " . "WHERE email = '{$userid}'"; $qh = doQuery($query, 101, "accounts"); if (!($userData = mysql_fetch_assoc($qh))) { return NULL; } $now = unixToDatetime(time()); // select desired data from db $query = "SELECT i.name AS IMtype, " . "u.IMid AS IMid, " . "u.affiliationid, " . "af.name AS affiliation, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.preferredname AS preferredname, " . "u.uid AS uid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "u.showallgroups " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND " . "u.uid = " . $userData["uid"]; $qh = doQuery($query, 255); // if get a row // update db // update results from select $esc_userid = mysql_escape_string($userid); $first = mysql_escape_string($userData['first']); $last = mysql_escape_string($userData['last']); $email = mysql_escape_string($userData['email']); if ($user = mysql_fetch_assoc($qh)) { $user["unityid"] = $userid; $user["firstname"] = $userData['first']; $user["lastname"] = $userData["last"]; $user["email"] = $userData["email"]; $user["lastupdated"] = $now; $query = "UPDATE user " . "SET unityid = '{$esc_userid}', " . "firstname = '{$first}', " . "lastname = '{$last}', " . "email = '{$email}', " . "lastupdated = '{$now}' " . "WHERE uid = " . $userData["uid"]; doQuery($query, 256, 'vcl', 1); } else { // call addITECSUser $id = addITECSUser($userid); $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.uid AS uid, " . "u.id AS id, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "u.showallgroups, " . "u.lastupdated AS lastupdated " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND " . "u.id = {$id}"; $qh = doQuery($query, 101); $user = mysql_fetch_assoc($qh); # add account to demo group $demoid = getUserGroupID('demo', getAffiliationID('ITECS')); updateGroups(array($demoid), $user['id']); } $user["groups"] = getUsersGroups($user["id"], 1); checkExpiredDemoUser($user['id'], $user['groups']); $user["privileges"] = getOverallUserPrivs($user["id"]); $tmparr = explode('@', $user['unityid']); $user['login'] = $tmparr[0]; return $user; }