case -3: //inactive //inactive case -4: //due G::SendMessageXml('ID_USER_INACTIVE', 'warning'); break; } if ($res < 0) { header('location: login.html'); die; } $uid = $res; $_SESSION['USER_LOGGED'] = $uid; $res = $RBAC->userCanAccess('RBAC_LOGIN'); if ($res != 1) { G::SendMessageXml('ID_USER_HAVENT_RIGHTS_PAGE', 'error'); header('location: login.html'); die; } $_SESSION['USER_NAME'] = $usr; $file = PATH_RBAC . PATH_SEP . 'class.authentication.php'; require_once $file; $obj = new authenticationSource(); $obj->SetTo($dbc); $res = $obj->verifyStructures(); if ($RBAC->userCanAccess("RBAC_READONLY") == 1) { header('location: ../rbac/userList'); } else { header('location: ../rbac/appList'); }
function searchText($searchText) { global $_SESSION; global $RBAC; $curAuthSource = $_SESSION['CURRENT_AUTH_SOURCE']; $dbc = new DBConnection(DB_HOST, DB_RBAC_USER, DB_RBAC_PASS, DB_RBAC_NAME); $tpl = new TemplatePower(PATH_TPL . 'authListUsers.html'); $tpl->prepare(); $tpl->assign("STYLE_CSS", defined('STYLE_CSS') ? STYLE_CSS : 'simple'); $tpl->assign("title", 'Search Results'); //authentication source G::LoadClassRBAC('authentication'); $obj = new authenticationSource(); $obj->SetTo($dbc); $data = $obj->searchUsers($curAuthSource, $searchText); if ($data['codError'] == 0 && isset($data['rows']) && !is_array($data['rows'])) { $tpl->newBlock("empty-rows"); $tpl->assign("title", 'Search Results'); $tpl->assign("empty-rows-text", 'no records found'); $tpl->printToScreen(); die; } if ($data['codError'] != 0) { $tpl->newBlock("error"); $tpl->assign("title", 'Log Error'); $tpl->assign("text", "<font color='Red'>" . $data['rows'] . "</font>"); $tpl->printToScreen(); die; } //build the options to create...an user, list the applications and their roles.. $ses = new DBSession($dbc); $ses2 = new DBSession($dbc); $dset = $ses->execute("SELECT * from APPLICATION where APP_CODE != 'RBAC' "); $appRow = $dset->Read(); $checkboxs = "<br><input type='checkbox' @@disabled name='C-@@Y' id='C-@@Y' onclick='emptyDropdowns( \"@@X\");' ><input type='hidden' name='H-@@Y' id='H-@@Y' value='@@X' ><input type='hidden' name='E-@@Y' id='E-@@Y' value='' >"; $inputs = "<div id='D-@@Y'>@@validuser</div><input type='text' name='T-@@Y' id='T-@@Y' value=\"@@Z\" onchange='verifyUserName ( this, \"@@Y\" );' size='14' maxlength='16'> "; $options = "<table cellpadding='0' cellspacing='0'><tr>"; $options .= ""; while (is_array($appRow)) { $appid = $appRow['UID']; $selectId = 'S-@@Y-' . $appid; $dset2 = $ses2->execute('SELECT * from ROLE where ROL_APPLICATION = ' . $appid); $rolRow = $dset2->Read(); $selectEnabled = false; if (is_array($rolRow)) { $options .= '<td>' . $appRow['APP_CODE'] . '<br>'; $options .= "<select name='{$selectId}' id='{$selectId}' @@disabled onchange='flipCheckbox( \"@@Y\");' >\n"; $options .= "<option value='0'>select a Role</option>"; $selectEnabled = true; } while (is_array($rolRow)) { $options .= "<option value='" . $rolRow['UID'] . "'>" . $rolRow['ROL_CODE'] . "</option>"; $rolRow = $dset2->Read(); } if ($selectEnabled) { $options .= "</select>\n<td>"; } $appRow = $dset->Read(); } $options .= '</tr></table>'; $i = 0; if (isset($data['rows'])) { foreach ($data['rows'] as $row) { $tpl->newBlock("users"); if (++$i % 2 == 0) { $tpl->assign("class", 'Row2'); } else { $tpl->assign("class", 'Row1'); } $tpl->assign("index", $i); $tpl->assign("dn", $row['dn']); $tpl->assign("name", $row['attr']['givenName']); $tpl->assign("lastname", $row['attr']['sn']); $tpl->assign("fullname", $row['attr']['cn']); $tpl->assign("email", $row['attr']['mail']); $tpl->assign("uid", $row['attr']['uid']); //verificar uid $userid = $row['attr']['uid']; $res = $RBAC->UserNameRepetido(0, $userid); $input = str_replace('@@Z', $userid, str_replace('@@X', $row['dn'], str_replace('@@Y', $i, $inputs))); $input = str_replace('@@validuser', $res == 0 ? "<font color='green'>valid user</font>" : "<font color='red'>user already used</font>", $input); $checkbox = str_replace('@@X', $row['dn'], str_replace('@@Y', $i, $checkboxs)); $checkbox = str_replace('@@disabled', $res != 0 ? 'disabled' : '', $checkbox); $option = str_replace('@@X', $row['dn'], str_replace('@@Y', $i, $options)); // $option = str_replace ( '@@disabled', ( $res <> 0 ? 'disabled' : ''), $option ); $tpl->assign("checkbox", $checkbox); $tpl->assign("input", $input); $tpl->assign("options", $option); } } $tpl->gotoBlock("_ROOT"); $tpl->newBlock("start-users"); $tpl->assign("dummy", 'dummy'); $tpl->gotoBlock("_ROOT"); $tpl->newBlock("end-users"); $tpl->assign("dummy", 'dummy'); $tpl->printToScreen(); }