public function usersLogin() { Logger::debug('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ')'); $logins = array(); $prefs = Preferences::getInstance(); if (!$prefs) { Logger::critical('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ') get prefs failed'); die_error('get Preferences failed', __FILE__, __LINE__); } $user_default_group = $prefs->get('general', 'user_default_group'); if ($user_default_group === $this->getUniqueID()) { // it's the default group -> we add all users $userdb = UserDB::getInstance(); $users = $userdb->getList(); foreach ($users as $a_user) { $logins[] = $a_user->getAttribute('login'); } } else { $ls = Abstract_Liaison::load('UsersGroup', NULL, $this->getUniqueID()); if (is_array($ls)) { foreach ($ls as $l) { $logins[] = $l->element; } } } return $logins; }
public function makeLDAPconfig($config_ = NULL) { if (is_null($config_) === false) { return $config_; } else { $userDBAD = UserDB::getInstance(); if (method_exists($userDBAD, 'makeLDAPconfig') === false) { Logger::error('main', 'UserGroupDB::ldap_posix::makeLDAPconfig makeLDAPconfig is not avalaible'); return NULL; } $configLDAP = $userDBAD->makeLDAPconfig(); $configLDAP['match'] = array(); if (array_key_exists('match', $this->preferences)) { $configLDAP['match'] = $this->preferences['match']; } $configLDAP['userbranch'] = ''; if (array_key_exists('group_dn', $this->preferences)) { $configLDAP['userbranch'] = $this->preferences['group_dn']; } if (array_key_exists('filter', $this->preferences)) { $configLDAP['filter'] = $this->preferences['filter']; } return $configLDAP; } }
public function get_login() { $userDB = UserDB::getInstance(); if (!is_object($userDB)) { return NULL; } $prefs = Preferences::getInstance(); $config = $prefs->get('AuthMethod', 'Auto'); if (array_key_exists('login', $_POST) && array_key_exists('uselogin', $config) && $config['uselogin'] == '1') { $this->login = $_POST['login']; } else { $this->login = '******' . gen_unique_string(); } $u = new User(); $u->setAttribute('login', $this->login); $u->setAttribute('password', $u->getAttribute('login')); $u->setAttribute('displayname', 'user ' . $u->getAttribute('login')); if ($userDB->add($u)) { $user = $userDB->import($u->getAttribute('login')); } else { Logger::error('main', 'AuthMethod::Auto::get_login failed to add user ' . $u->getAttribute('login')); return NULL; } if (!is_object($user)) { return NULL; } $this->login = $user->getAttribute('login'); return $this->login; }
function search() { $userDB = UserDB::getInstance(); list($this->result, $nb) = $userDB->getUsersContains($this->search_item, $this->search_fields, $this->search_limit + 1); if ($nb || count($this->result) > $this->search_limit) { array_pop($this->result); $this->partial_result = true; } else { $this->partial_result = false; } return $this->result; }
public function getUsers() { $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id); if (is_array($liaisons) == false) { Logger::error('main', 'NetworkFolder::getUsers()'); return false; } $userDB = UserDB::getInstance(); $users = array(); foreach ($liaisons as $liaison) { array_push($users, $liaison->element); } return $userDB->imports($users); }
public function getUsers() { $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id); if (is_array($liaisons) == false) { Logger::error('main', 'NetworkFolder::getUsers()'); return false; } $userDB = UserDB::getInstance(); $users = array(); foreach ($liaisons as $liaison) { $user = $userDB->import($liaison->element); if (!is_object($user)) { continue; } $users[$user->getAttribute('login')] = $user; } return $users; }
public function checkPendingSession($session_) { $sessions = Abstract_Session::getByUser($session_->user_login); foreach ($sessions as $i => $session) { if ($session->id == $session_->id) { unset($sessions[$i]); continue; } } if (count($sessions) != 1) { return true; } $session = reset($sessions); if ($session->need_creation == 0) { return true; } // Start the creation try { $sessionManagement = SessionManagement::getInstance(); } catch (Exception $err) { Logger::error('main', "SessionStatusChangedPendingSessionCreation:: Failed to get SessionManagement instance"); return false; } if (!$sessionManagement->initialize()) { Logger::error('main', "SessionStatusChangedPendingSessionCreation:: SessionManagement initialization failed"); return false; } $userDB = UserDB::getInstance(); $user = $userDB->import($session->user_login); if (!is_object($user)) { Logger::error('main', 'SessionStatusChangedPendingSessionCreation:: Unable to import a valid user with login "' . $session->user_login . '"'); return false; } $sessionManagement->user = $user; if (!$sessionManagement->prepareSession($session)) { Logger::error('main', "SessionStatusChangedPendingSessionCreation:: SessionManagement initialization failed"); return false; } // prepareSession can take some time $session = Abstract_Session::load($session->id); $session->need_creation = 0; Abstract_Session::save($session); return true; }
function authenticate_ovd_user($login_, $password_) { // it's not the login&password from the conf file in /etc // let's try to login a real user if (Preferences::fileExists() === false) { $_SESSION['admin_error'] = _('The system is not configured'); Logger::info('main', 'admin/login.php::authenticate_ovd_user the system is not configured'); return false; } if (Preferences::moduleIsEnabled('UserDB') === false) { $_SESSION['admin_error'] = _('The module UserDB is not enabled'); Logger::info('main', 'admin/login.php::authenticate_ovd_user module UserDB is not enabled'); return false; } $userDB = UserDB::getInstance(); $user = $userDB->import($login_); if (!is_object($user)) { // the user does not exist $_SESSION['admin_error'] = _('There was an error with your authentication'); Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed: user(login='******') does not exist'); return false; } $auth = $userDB->authenticate($user, $password_); if (!$auth) { $_SESSION['admin_error'] = _('There was an error with your authentication'); Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed for user(login='******'): wrong password'); return false; } // the user exists, does he have right to log in the admin panel ? $policy = $user->getPolicy(); if (isset($policy['canUseAdminPanel']) && $policy['canUseAdminPanel'] == true) { return $user; } Logger::info('main', 'login.php failed to log in ' . $login_ . ' : access denied to admin panel'); $_SESSION['admin_error'] = _('Unauthorized access'); return false; }
public function authenticate() { $this->userDB = UserDB::getInstance(); if (isset($_SESSION) && is_array($_SESSION) && array_key_exists('user_login', $_SESSION)) { $this->user = $this->userDB->import($_SESSION['user_login']); if (!is_object($this->user)) { Logger::debug('main', 'SessionManagement::authenticate - Unable to import a valid user with login "' . $_SESSION['user_login'] . '"'); return false; } return true; } $authMethods_enabled = $this->prefs->get('AuthMethod', 'enable'); if (!is_array($authMethods_enabled)) { Logger::error('main', 'SessionManagement::authenticate - No AuthMethod enabled'); return false; } $authMethods = array(); foreach ($this->getAuthMethods() as $authMethod_name_) { if (!in_array($authMethod_name_, $authMethods_enabled)) { Logger::debug('main', 'SessionManagement::authenticate - AuthMethod "' . $authMethod_name_ . '" is not enabled'); continue; } $authMethods[$authMethod_name_] = $authMethod_name_; } if (array_key_exists('Password', $authMethods)) { unset($authMethods['Password']); $authMethods['Password'] = '******'; } foreach ($authMethods as $authMethod_name_) { $authMethod_module = 'AuthMethod_' . $authMethod_name_; $authMethod = new $authMethod_module($this->prefs, $this->userDB, $this->user_node_request); Logger::debug('main', 'SessionManagement::authenticate - Trying "' . $authMethod_module . '"'); $user_login = $authMethod->get_login(); if (is_null($user_login)) { Logger::debug('main', 'SessionManagement::authenticate - Unable to get a valid login'); continue; } $this->user = $this->userDB->import($user_login); if (!is_object($this->user)) { Logger::debug('main', 'SessionManagement::authenticate - Unable to import a valid user with login "' . $user_login . '"'); continue; } $buf = $authMethod->authenticate($this->user); if ($buf === true) { $this->authMethod = $authMethod; Logger::debug('main', 'SessionManagement::authenticate - Now authenticated as "' . $user_login . '"'); return true; } Logger::error('main', 'SessionManagement::authenticate - Authentication failed for "' . $user_login . '"'); continue; } Logger::error('main', 'SessionManagement::authenticate - Authentication failed'); $this->user = false; return false; }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php'; require_once dirname(__FILE__) . '/../includes/webservices.inc.php'; $dom = new DomDocument('1.0', 'utf-8'); $root = $dom->createElement('auth'); $dom->appendChild($root); $prefs = Preferences::getInstance(); if ($prefs) { $userDB = UserDB::getInstance(); $authMethods_enabled = $prefs->get('AuthMethod', 'enable'); if (is_array($authMethods_enabled)) { foreach ($authMethods_enabled as $authMethod_name) { $authMethod_module = 'AuthMethod_' . $authMethod_name; $authMethod = new $authMethod_module($prefs, $userDB, null); $authMethodParams = $authMethod->getClientParameters(); if (is_array($authMethodParams) && count($authMethodParams) > 0) { $snode = $dom->createElement($authMethod_name); $root->appendChild($snode); foreach ($authMethodParams as $key => $value) { $node = $dom->createElement($key); $text_node = $dom->createTextNode($value); $node->appendChild($text_node); $snode->appendChild($node); }
function show_manage($id_) { // $session = Abstract_ReportSession::load($id_); $session = get_session_reporting($id_); if (!$session) { popup_error(sprintf(_('Unknown session %s'), $id_)); redirect(); } $userDB = UserDB::getInstance(); $user = $userDB->import($session['user']); $applicationDB = ApplicationDB::getInstance(); $applications = array(); $dom = new DomDocument('1.0', 'utf-8'); $ret = @$dom->loadXML($session['data']); if ($ret) { foreach ($dom->getElementsByTagName('application') as $node) { $application = array(); foreach ($node->childNodes as $child_node) { $name = $child_node->nodeName; if ($name == '#text') { continue; } $application[$name] = $child_node->nodeValue; } $applications[] = $application; } } for ($i = 0; $i < count($applications); $i++) { $app_buf = $applicationDB->import($applications[$i]['id']); if (is_object($app_buf)) { $applications[$i]["obj"] = $app_buf; } } page_header(); echo '<h1>' . str_replace('%ID%', $session['id'], _('Archived session - %ID%')) . '</h1>'; echo '<ul>'; echo '<li><strong>' . _('User:'******'</strong> '; if (is_object($user)) { echo '<a href="users.php?action=manage&id=' . $user->getAttribute('login') . '">' . $user->getAttribute('displayname') . '</a>'; } else { echo $session['user'] . ' <span><em>' . _('Not existing anymore') . '</em></span>'; } echo '</li>'; echo '<li><strong>' . _('Started:') . '</strong> '; echo $session['start_stamp']; echo '</li>'; echo '<li><strong>' . _('Stopped:') . '</strong> '; echo $session['stop_stamp']; if (isset($session['stop_why']) && strlen($session['stop_why']) > 0) { echo ' <em>(' . $session['stop_why'] . ')</em>'; } echo '</li>'; echo '</ul>'; if (count($applications) > 0) { echo '<div>'; echo '<h2>' . _('Used applications') . '</h2>'; echo '<ul>'; foreach ($applications as $application) { echo '<li>'; if (isset($application['obj'])) { echo '<img src="media/image/cache.php?id=' . $application['obj']->getAttribute('id') . '" alt="" title="" /> '; echo '<a href="applications.php?action=manage&id=' . $application['obj']->getAttribute('id') . '">' . $application['obj']->getAttribute('name') . '</a>'; } else { echo $application['id'] . ' <span><em>' . _('not existing anymore') . '</em></span>'; } if ($application['start'] - $application['start'] > 0) { echo ' - (' . ($application['start'] - $application['start']) / 60 . 'm)'; } echo '</li>'; } echo '</ul>'; echo '</div>'; } page_footer(); die; }
public static function loadParentsGroups($group_) { Logger::debug('main', "Abstract_Liaison_activedirectory::loadParentsGroups ({$group_})"); $userDBAD2 = new UserDB_activedirectory(); $userDBAD = UserDB::getInstance(); if (get_class($userDBAD) == get_class($userDBAD2)) { $userDBAD = $userDBAD2; // for cache } $userGroupDB = UserGroupDB::getInstance(); $groups = array(); $u = $userDBAD->importFromDN($group_); if (is_null($u)) { return $groups; } if (!$u->hasAttribute('memberof')) { return $groups; } $memberof = $u->getAttribute('memberof'); if (is_string($memberof)) { $memberof = array($memberof); } foreach ($memberof as $id_group) { $g = $userGroupDB->import('static_' . $id_group); if (!is_object($g)) { continue; } $groups[] = $g; $parent_groups = self::loadParentsGroups($id_group); $groups = array_merge($groups, $parent_groups); } return $groups; }
function show_step5() { page_header(); echo '<div>'; echo '<h1><a href="wizard.php">' . _('Publication Wizard') . '</a> - ' . _('Confirmation') . '</h1>'; echo '<p>' . _('Are you sure that you want to create this publication?') . '</p>'; echo '<table style="width: 50%;" border="0" cellspacing="1" cellpadding="3">'; echo '<tr>'; echo '<td style="text-align: left; vertical-align: top;">'; echo '<div class="container rounded" style="background: #eee;">'; if ($_SESSION['wizard']['use_users'] == 'usergroups') { $usergroupDB = UserGroupDB::getInstance(); echo '<p style="font-weight: bold;">'; if (count($_SESSION['wizard']['usergroups']) == 1) { echo _('Between this users group'); } else { echo _('Between these users groups'); } echo '</p>'; echo '<ul>'; foreach ($_SESSION['wizard']['usergroups'] as $ug_id) { $ug = $usergroupDB->import($ug_id); if (!is_object($ug)) { Logger::warning('main', '(admin/wizard) Usergroup \'' . $ug_id . '\' import failed'); continue; } echo '<li>' . $ug->name . '</li>'; } echo '</ul>'; } elseif ($_SESSION['wizard']['use_users'] == 'users') { $userDB = UserDB::getInstance(); echo '<p style="font-weight: bold;">'; echo _('Between this newly created users group'); echo '</p>'; echo '<ul>'; echo '<li><strong>' . _('Name:') . '</strong> ' . $_SESSION['wizard']['user_group_name'] . '</li>'; echo '<li><strong>' . _('Description: ') . '</strong> ' . $_SESSION['wizard']['user_group_description'] . '</li>'; echo '<li><strong>' . _('Users:') . '</strong> <ul>'; foreach ($_SESSION['wizard']['users'] as $user_login) { $user = $userDB->import($user_login); if (!is_object($user)) { Logger::warning('main', '(admin/wizard) User \'' . $user_login . '\' import failed'); continue; } echo '<li>' . $user->getAttribute('displayname') . '</li>'; } echo '</ul></li>'; echo '</ul>'; } echo '</div>'; echo '</td>'; echo '<td style="width: 50px;">'; echo '</td>'; echo '<td style="text-align: left; vertical-align: top;">'; echo '<div class="container rounded" style="background: #eee;">'; if ($_SESSION['wizard']['use_apps'] == 'appgroups') { $applicationsGroupDB = ApplicationsGroupDB::getInstance(); echo '<p style="font-weight: bold;">'; if (count($_SESSION['wizard']['appgroups']) == 1) { echo _('and this applications group'); } else { echo _('and these applications groups'); } echo '</p>'; echo '<ul>'; foreach ($_SESSION['wizard']['appgroups'] as $ag_id) { $appgroup = $applicationsGroupDB->import($ag_id); if (is_object($appgroup)) { echo '<li>' . $appgroup->name . '</li>'; } } echo '</ul>'; } elseif ($_SESSION['wizard']['use_apps'] == 'apps') { $applicationDB = ApplicationDB::getInstance(); echo '<p style="font-weight: bold;">'; echo _('and this newly created applications group'); echo '</p>'; echo '<ul>'; echo '<li><strong>' . _('Name:') . '</strong> ' . $_SESSION['wizard']['application_group_name'] . '</li>'; echo '<li><strong>' . _('Description: ') . '</strong> ' . $_SESSION['wizard']['application_group_description'] . '</li>'; echo '<li><strong>' . _('Applications:') . '</strong> <ul>'; foreach ($_SESSION['wizard']['apps'] as $application_id) { $application = $applicationDB->import($application_id); if (!is_object($application)) { Logger::warning('main', '(admin/wizard) Application \'' . $application_id . '\' import failed'); continue; } echo '<li>' . $application->getAttribute('name') . '</li>'; } echo '</ul></li>'; echo '</ul>'; } echo '</div>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '<form action="" method="post">'; echo '<input type="hidden" name="from" value="step5" />'; echo '<table style="width: 50%;" class="" border="0" cellspacing="1" cellpadding="5">'; echo '<tr>'; echo '<td colspan="2">'; echo '<table style="width: 100%;" border="0" cellspacing="0" cellpadding="0">'; echo '<tr>'; echo '<td style="text-align: left;">'; echo '<input type="submit" name="submit_previous" value="' . _('Previous') . '" />'; echo '</td>'; echo '<td style="text-align: right;">'; echo '<input type="submit" name="submit_next" value="' . _('Confirm') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; echo '</div>'; page_footer(); die; }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_unix::loadGroups ({$type_},{$element_})"); $groups = array(); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $element_user = $userDB->import($element_); if (!is_object($element_user)) { Logger::error('main', "Abstract_Liaison_unix::loadGroups load element ({$element_}) failed"); return NULL; } $userGroupDB = UserGroupDB::getInstance(); $groups_list = $userGroupDB->getList(); foreach ($groups_list as $group) { $liaisons = self::loadElements($type_, $group->getUniqueID()); if (is_array($liaisons)) { foreach ($liaisons as $liaison) { $l = new Liaison($element_user->getAttribute('login'), $group->getUniqueID()); $groups[$l->group] = $l; } } } return $groups; }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_ldap_posix::loadGroups ({$type_},{$element_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $groups = array(); $groups_all = $userGroupDB->getList(); if (!is_array($groups_all)) { Logger::error('main', 'Abstract_Liaison_ldap::loadGroups userGroupDB->getList failed'); return NULL; } foreach ($groups_all as $a_group) { if (in_array($element_, $a_group->usersLogin())) { $l = new Liaison($element_, $a_group->getUniqueID()); $groups[$l->group] = $l; } } return $groups; }
function show_default() { $userDB = UserDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $sessionmanagement = SessionManagement::getInstance(); $usersList = new UsersList($_REQUEST); $us = $usersList->search(); $searchDiv = $usersList->getForm(); page_header(); echo '<h2>' . _('List of users') . '</h2>'; echo $searchDiv; if (count($us) == 0) { echo _('No available user') . '<br />'; } else { echo '<table id="users_table" class="main_sub sortable" border="0" cellspacing="1" cellpadding="3">'; echo '<thead>'; echo '<tr class="title2">'; echo '<th class="unsortable" colspan="3">' . _('Users') . '</th>'; echo '<th colspan="2">' . _('Applications') . '</th>'; echo '<th>' . _('Folders') . '</th>'; echo '<th>' . _('Session') . '</th>'; echo '</tr>'; echo '<tr class="title">'; echo '<th>' . _('Login') . '</th>'; echo '<th>' . _('Name') . '</th>'; echo '<th>' . _('In these users groups') . '</th>'; echo '<th>' . _('Published applications groups') . '</th>'; echo '<th>' . _('Access to these applications') . '</th>'; echo '<th>' . _('Access to these folders') . '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; $count = 0; foreach ($us as $u) { $session_settings_defaults = $u->getSessionSettings('session_settings_defaults'); echo '<tr class="content'; if ($count % 2 == 0) { echo '1'; } else { echo '2'; } echo '">'; echo '<td><a href="users.php?action=manage&id=' . $u->getAttribute('login') . '">' . $u->getAttribute('login') . '</a></td>'; // login echo '<td><a href="users.php?action=manage&id=' . $u->getAttribute('login') . '">' . $u->getAttribute('displayname') . '</a></td>'; //nam $users_grps = $u->usersGroups(); // in user group echo '<td>'; if (count($users_grps) == 0) { echo '<em>' . _('Not in any users group') . '</em>'; } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($users_grps as $ugrp) { echo '<tr>'; echo '<td><a href="usersgroup.php?action=manage&id=' . $ugrp->getUniqueID() . '">' . $ugrp->name . '</a></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; $apps_grps = $u->appsGroups(); if (count($apps_grps) == 0) { echo '<td colspan="2">'; echo '<em>' . _('No publication') . '</em>'; echo '</td>'; } else { echo '<td>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($apps_grps as $agrp_id) { $agrp = $applicationsGroupDB->import($agrp_id); if (is_object($agrp)) { echo '<tr>'; echo '<td><a href="appsgroup.php?action=manage&id=' . $agrp->id . '">' . $agrp->name . '</a></td>'; echo '</tr>'; } } echo '</table>'; echo '</td>'; echo '<td>'; // in app $apps_s = $u->applications(); if (count($apps_s) == 0) { echo '<em>' . _('No applications in these groups') . '</em>'; } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($apps_s as $aaa) { echo '<tr>'; echo '<td><img src="media/image/cache.php?id=' . $aaa->getAttribute('id') . '" alt="" title="" /></td>'; echo '<td><a href="applications.php?action=manage&id=' . $aaa->getAttribute('id') . '">' . $aaa->getAttribute('name') . '</a></td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $aaa->getAttribute('type') . '.png" width="16" height="16" alt="' . $aaa->getAttribute('type') . '" title="' . $aaa->getAttribute('type') . '" /></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; } echo '<td>'; $folders = array(); if (array_key_exists('enable_sharedfolders', $session_settings_defaults) && $session_settings_defaults['enable_sharedfolders'] == 1) { $folders = $u->getSharedFolders(); } $profiles = array(); if (array_key_exists('enable_profiles', $session_settings_defaults) && $session_settings_defaults['enable_profiles'] == 1) { $profiles = $u->getProfiles(); } $networkfolder_s = array_merge($folders, $profiles); if (count($networkfolder_s) > 0) { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($networkfolder_s as $a_networkfolder) { echo '<tr>'; echo '<td>' . $a_networkfolder->prettyName() . '</td>'; if (isset($a_networkfolder->name) && $a_networkfolder->name !== '') { $name = $a_networkfolder->name; } else { $name = $a_networkfolder->id; } echo '<td>'; if (isset($a_networkfolder->name)) { $page = 'sharedfolders'; } else { $page = 'profiles'; } echo '<a href="' . $page . '.php?action=manage&id=' . $a_networkfolder->id . '">' . $name . '</a></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; echo '<td style="text-align: center;">'; // server $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $u; $can_start_session = $sessionmanagement2->buildServersList(); if ($can_start_session === true) { echo '<img src="media/image/ok.png" alt="" title="" />'; } else { echo '<img src="media/image/cancel.png" alt="" title="" />'; } echo '</td>'; echo '</tr>'; $count++; } echo '</tbody>'; echo '</table>'; } page_footer(); }
function show_manage($id) { global $schedules; $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $userGroupDB = UserGroupDB::getInstance(); $group = $userGroupDB->import($id); if (!is_object($group)) { die_error(_('Failed to load usergroup')); } $usergroupdb_rw = $userGroupDB->isWriteable(); $policy = $group->getPolicy(); $policy_rule_enable = 0; $policy_rules_disable = 0; foreach ($policy as $key => $value) { if ($value === true) { $policy_rule_enable++; } else { $policy_rules_disable++; } } $buffer = $prefs_policy = $prefs->get('general', 'policy'); $default_policy = $prefs_policy['default_policy']; if (!is_object($group)) { die_error('Group "' . $id . '" is not OK', __FILE__, __LINE__); } if ($group->published) { $status = '<span class="msg_ok">' . _('Enabled') . '</span>'; $status_change = _('Block'); $status_change_value = 0; } else { $status = '<span class="msg_error">' . _('Blocked') . '</span>'; $status_change = _('Enable'); $status_change_value = 1; } $userDB = UserDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); if ($group->isDefault() == false) { $users = $group->usersLogin(); sort($users); $has_users = count($users) > 0; if ($usergroupdb_rw) { $usersList = new UsersList($_REQUEST); $users_all = $usersList->search(); $search_form = $usersList->getForm(array('action' => 'manage', 'id' => $id, 'search_user' => true)); if (is_null($users_all)) { $users_all = array(); } $users_available = array(); foreach ($users_all as $user) { $found = false; foreach ($users as $user2) { if ($user2 == $user->getAttribute('login')) { $found = true; } } if (!$found) { $users_available[] = $user->getAttribute('login'); } } } else { $users_available = array(); $users_all = array(); foreach ($users as $a_login) { $users_all[] = $userDB->import($a_login); } usort($users_all, "user_cmp"); } } else { $users = array(); $users_available = array(); $users_all = array(); $search_form = null; } // Default usergroup $is_default_group = $prefs->get('general', 'user_default_group') == $id; // Publications $groups_apps = array(); foreach (Abstract_Liaison::load('UsersGroupApplicationsGroup', $id, NULL) as $group_a) { $obj = $applicationsGroupDB->import($group_a->group); if (is_object($obj)) { $groups_apps[] = $obj; } } $groups_apps_all = $applicationsGroupDB->getList(); $groups_apps_available = array(); foreach ($groups_apps_all as $group_apps) { if (!in_array($group_apps, $groups_apps)) { $groups_apps_available[] = $group_apps; } } $can_manage_usersgroups = isAuthorized('manageUsersGroups'); $can_manage_publications = isAuthorized('managePublications'); $can_manage_sharedfolders = isAuthorized('manageServers'); $prefs_to_get_for_a_group = array('session_settings_defaults', 'remote_desktop_settings', 'remote_applications_settings'); $prefs_of_a_group = array(); $unuse_settings = array(); $session_prefs = array(); foreach ($prefs_to_get_for_a_group as $prefs_to_get_for_a_group_value) { $prefs_of_a_group[$prefs_to_get_for_a_group_value] = array(); $unuse_settings[$prefs_to_get_for_a_group_value] = array(); $session_prefs[$prefs_to_get_for_a_group_value] = $prefs->getElements('general', $prefs_to_get_for_a_group_value); $prefs_of_a_group_unsort = Abstract_UserGroup_Preferences::loadByUserGroupId($group->getUniqueID(), 'general', $prefs_to_get_for_a_group_value); foreach ($session_prefs[$prefs_to_get_for_a_group_value] as $k4 => $v4) { // we should use the ones from the group ($prefs_of_a_group_unsort) but we can display then if they are in $session_prefs if (array_key_exists($k4, $prefs_of_a_group_unsort)) { $prefs_of_a_group[$prefs_to_get_for_a_group_value][$k4] = $prefs_of_a_group_unsort[$k4]; } else { $unuse_settings[$prefs_to_get_for_a_group_value][$k4] = $v4; } } } page_header(); echo '<div id="users_div">'; echo '<h1><a href="?">' . _('User groups management') . '</a> - ' . $group->name . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; echo '<tr class="title">'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Status') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $group->description . '</td>'; echo '<td>' . $status . '</td>'; echo '</tr>'; echo '</table>'; if ($can_manage_usersgroups) { echo '<div>'; echo '<h2>' . _('Settings') . '</h1>'; if ($group->type == 'static' and $can_manage_usersgroups and $usergroupdb_rw) { echo '<form action="actions.php" method="post">'; if ($is_default_group) { echo '<input type="submit" value="' . _('Remove from default') . '"/>'; echo '<input type="hidden" name="action" value="unset_default" />'; } else { echo '<input type="submit" value="' . _('Define as default') . '"/>'; echo '<input type="hidden" name="action" value="set_default" />'; } echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '</form>'; echo '<br/>'; } if ($usergroupdb_rw || $group->type != 'static') { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this group?') . '\');">'; echo '<input type="submit" value="' . _('Delete this group') . '"/>'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_groups[]" value="' . $id . '" />'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="hidden" name="published" value="' . $status_change_value . '" />'; echo '<input type="submit" value="' . $status_change . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="name_group" value="' . $group->name . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the name') . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="description" value="' . $group->description . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the description') . '"/>'; echo '</form>'; } if ($group->type == 'dynamiccached') { echo '<br />'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo ' <select name="schedule">'; foreach ($schedules as $interval => $text) { echo '<option value="' . $interval . '"'; if ($group->schedule == $interval) { echo ' selected="selected"'; } echo '>' . $text . '</option>'; } echo '</select>'; echo '<input type="submit" value="' . _('Update the schedule') . '"/>'; echo '</form>'; } echo '</div>'; echo '<br/>'; } if (str_startswith($group->type, 'dynamic')) { echo '<div>'; echo '<h2>' . _('Rules') . '</h1>'; if ($can_manage_usersgroups) { echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify_rules" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; } echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="content1">'; echo '<th>' . _('Validation type') . '</th>'; echo '<td><input type="radio" name="validation_type" value="and"'; if ($group->validation_type == 'and') { echo ' checked="checked"'; } echo ' /> ' . _('All') . ' <input type="radio" name="validation_type" value="or"'; if ($group->validation_type == 'or') { echo ' checked="checked"'; } echo ' /> ' . _('At least one') . '</td>'; echo '</tr>'; echo '<tr class="content2">'; echo '<th>' . _('Filters') . '</th>'; echo '<td>'; $i = 0; $filter_attributes = $userDB->getAttributesList(); foreach ($filter_attributes as $key1 => $value1) { if ($value1 == 'password') { unset($filter_attributes[$key1]); } } $filter_types = UserGroup_Rule::$types; echo '<table border="0" cellspacing="1" cellpadding="3">'; $i = 0; foreach ($group->rules as $rule) { echo '<tr>'; echo '<td><select name="rules[' . $i . '][attribute]">'; foreach ($filter_attributes as $filter_attribute) { echo '<option value="' . $filter_attribute . '"'; if ($rule->attribute == $filter_attribute) { echo ' selected="selected"'; } echo '>' . $filter_attribute . '</option>'; } echo '</select></td>'; echo '<td><select name="rules[' . $i . '][type]">'; foreach ($filter_types as $filter_type) { echo '<option value="' . $filter_type . '"'; if ($rule->type == $filter_type) { echo ' selected="selected"'; } echo '>' . $filter_type . '</option>'; } echo '</select></td>'; echo '<td><input type="text" name="rules[' . $i . '][value]" value="' . $rule->value . '" /></td>'; if ($can_manage_usersgroups) { echo '<td>'; echo '<input'; if ($i == 0 && count($group->rules) == 1 || $i == count($group->rules)) { echo ' style="display: none;"'; } echo ' type="button" onclick="del_field(this.parentNode.parentNode); return false;" value="-" />'; echo '<input'; if ($i + 1 != count($group->rules)) { echo ' style="display: none;"'; } echo ' type="button" onclick="add_field(this.parentNode.parentNode); return false;" value="+" />'; echo '</td>'; } echo '</tr>'; $i++; } echo '</table>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '<br />'; if ($can_manage_usersgroups) { echo '<input type="submit" value="' . _('Update rules') . '" />'; echo '</form>'; } echo '</div>'; echo '<br />'; } // Users list if (count($users_all) > 0 || count($users) > 0 || $group->isDefault()) { echo '<div>'; echo '<h2>' . _('List of users in this group') . '</h2>'; if ($group->isDefault()) { echo _('All available users are in this group.'); } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($users) > 0) { foreach ($users as $user) { echo '<tr>'; echo '<td><a href="users.php?action=manage&id=' . $user . '">' . $user . '</td>'; echo '<td>'; if ($usergroupdb_rw && $group->type == 'static' && !$group->isDefault() and $can_manage_usersgroups) { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="User_UserGroup" />'; echo '<input type="hidden" name="group" value="' . $id . '" />'; echo '<input type="hidden" name="element" value="' . $user . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($users_available) > 0 && $usergroupdb_rw && $group->type == 'static' and $can_manage_usersgroups) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="User_UserGroup" />'; echo '<input type="hidden" name="group" value="' . $id . '" />'; echo '<select name="element">'; foreach ($users_available as $user) { echo '<option value="' . $user . '" >' . $user . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; if ($usergroupdb_rw && $group->type == 'static' and $can_manage_usersgroups) { echo '<br/>'; echo $search_form; } echo '</div>'; echo '<br/>'; } } // Publications part if (count($groups_apps_all) > 0) { echo '<div>'; echo '<h2>' . _('List of publications for this group') . '</h1>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($groups_apps) > 0) { foreach ($groups_apps as $groups_app) { echo '<tr>'; echo '<td><a href="appsgroup.php?action=manage&id=' . $groups_app->id . '">' . $groups_app->name . '</td>'; if ($can_manage_publications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this publication?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_u" value="' . $id . '" />'; echo '<input type="hidden" name="group_a" value="' . $groups_app->id . '" />'; echo '<input type="submit" value="' . _('Delete this publication') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($groups_apps_available) > 0 and $can_manage_publications) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_u" value="' . $id . '" />'; echo '<select name="group_a">'; foreach ($groups_apps_available as $group_apps) { echo '<option value="' . $group_apps->id . '" >' . $group_apps->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add this publication') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } // Policy of this group echo '<div>'; echo '<h2>' . _('Policy of this group') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($policy as $key => $value) { if ($value === false) { continue; } $extends_from_default = in_array($key, $default_policy); $buffer = $extends_from_default === true ? ' (' . _('extend from default') . ')' : ''; echo '<tr>'; echo '<td>' . $key . ' ' . $buffer . '</td>'; if ($can_manage_usersgroups && !$extends_from_default) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this rule?') . '\');">'; echo '<input type="hidden" name="name" value="UserGroup_PolicyRule" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '<input type="hidden" name="element" value="' . $key . '" />'; echo '<input type="submit" value="' . _('Delete this rule') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } if ($can_manage_usersgroups && count($policy_rules_disable) > 0 && array_search(false, $policy) !== false) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="UserGroup_PolicyRule" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '<select name="element">'; foreach ($policy as $key => $value) { if ($value === true) { continue; } echo '<option value="' . $key . '" >' . $key . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add this rule') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; echo '<br/>'; if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $all_sharedfolders = $sharedfolderdb->getList(); if (count($all_sharedfolders) > 0) { $available_sharedfolders = array(); $used_sharedfolders = $sharedfolderdb->importFromUsergroup($group->getUniqueID()); foreach ($all_sharedfolders as $sharedfolder) { if (in_array($sharedfolder->id, array_keys($used_sharedfolders))) { continue; } $available_sharedfolders[] = $sharedfolder; } echo '<br />'; echo '<div>'; echo '<h2>' . _('Shared folders') . '</h1>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($used_sharedfolders as $sharedfolder) { echo '<tr>'; echo '<td><a href="sharedfolders.php?action=manage&id=' . $sharedfolder->id . '">' . $sharedfolder->name . '</a></td>'; if ($can_manage_sharedfolders) { echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this shared folder access?') . '\');">'; echo '<input type="hidden" name="name" value="SharedFolder_ACL" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="sharedfolder_id" value="' . $sharedfolder->id . '" />'; echo '<input type="hidden" name="usergroup_id" value="' . $group->getUniqueID() . '" />'; echo '<input type="submit" value="' . _('Delete access to this shared folder') . '" />'; echo '</form></td>'; } echo '</tr>'; } if (count($available_sharedfolders) > 0 && $can_manage_sharedfolders) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="SharedFolder_ACL" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="usergroup_id" value="' . $group->getUniqueID() . '" />'; echo '<select name="sharedfolder_id">'; foreach ($available_sharedfolders as $sharedfolder) { echo '<option value="' . $sharedfolder->id . '" >' . $sharedfolder->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add access to this shared folder') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } echo '<br />'; } echo '<div>'; // Session settings configuration echo '<h2>'; echo _('Session settings configuration'); echo '</h2>'; if ($prefs_of_a_group != array()) { foreach ($prefs_of_a_group as $container => $prefs_of_a_group_value) { echo '<fieldset class="prefssessionusergroup">'; echo '<legend>' . $prefs->getPrettyName($container) . '</legend>'; echo '<form action="actions.php" method="post">'; $key_name = 'general'; echo '<input type="hidden" name="container" value="' . $container . '" />'; // from admin/functions.inc.php $color = 0; if (count($prefs_of_a_group_value) != 0) { echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3" style="margin-bottom: 10px;">'; // TODO echo '<tr class="title">'; echo '<th>' . _('Name') . '</th>'; echo '<th>' . _('Default value') . '</th>'; echo '<th>' . _('Value') . '</th>'; echo '<th>' . _('Action') . '</th>'; echo '<tr>'; foreach ($prefs_of_a_group_value as $element_key => $usersgroup_preferences) { $config_element = $usersgroup_preferences->toConfigElement(); echo '<tr class="content' . ($color % 2 + 1) . '">'; echo '<td style="width: 250px;">'; echo '<span onmouseover="showInfoBulle(\'' . str_replace("'", "’", $config_element->description_detailed) . '\'); return false;" onmouseout="hideInfoBulle(); return false;">' . $config_element->label . '</span>'; echo '<td>'; $default_element = $session_prefs[$container][$config_element->id]; $default_element->setFormSeparator('NaN'); // it must be different of ___ $default_element->setPath(array('key_name' => $key_name, 'container' => $container, 'element_id' => $config_element->id)); echo $default_element->toHTML(true); echo '</td>'; echo '</td>'; echo '<td style="padding: 3px;">'; print_element($key_name, $container, $element_key, $config_element); echo '</td>'; echo '<td>'; echo '<input type="button" value="' . _('Remove this overriden setting') . '" onclick="usergroup_settings_remove(\'' . $group->getUniqueID() . '\',\'' . $container . '\',\'' . $config_element->id . '\'); return false;"/>'; echo '</td>'; echo '</tr>'; $color++; } // end from echo '<tr class="content' . ($color % 2 + 1) . '">'; echo '<td colspan="3"></td>'; echo '<td>'; echo '<input type="hidden" name="name" value="UserGroup_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $group->getUniqueID() . '" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="submit" value="' . _('Save settings') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; } if ($unuse_settings[$container] != array()) { echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $group->getUniqueID() . '" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<select name="element_id">'; foreach ($unuse_settings[$container] as $setting_name => $setting_content) { echo '<option value="' . $setting_name . '" >' . $setting_content->label . '</option>'; } echo '</select>'; echo ' '; echo '<input type="submit" value="' . _('Add this setting') . '" />'; echo '</form>'; } echo '</fieldset>'; } } echo '</div>'; // Session settings configuration echo "\n\n\n"; echo '</div>'; page_footer(); die; }
<?php require_once "Includes/db.php"; $logonSuccess = false; // verify user's credentials if ($_SERVER['REQUEST_METHOD'] == "POST") { $user = filter_input(INPUT_POST, 'user'); $userpassword = filter_input(INPUT_POST, 'userpassword'); $logonSuccess = UserDB::getInstance()->verify_users_credentials($user, $userpassword); if ($logonSuccess == true) { session_start(); $_SESSION['user'] = $_POST['user']; header('Location: menu.php'); exit; } else { header('Location:users/users.php'); //register new user exit; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Inventory Control System</title> <link href="wishlist.css" type="text/css" rel="stylesheet" media="all" /> </head> <body>
function checkup_liaison($type_, $element_, $group_) { switch ($type_) { case 'ApplicationServer': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } $buf = Abstract_Server::load($group_); if (!$buf) { return 'Server "' . $group_ . '" does not exist'; } break; case 'AppsGroup': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $buf = $applicationsGroupDB->import($group_); if (!is_object($buf)) { return 'ApplicationsGroup "' . $group_ . '" does not exist'; } break; case 'ApplicationMimeType': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } break; case 'ServerSession': $buf = Abstract_Server::load($element_); if (!$buf) { return 'Server "' . $element_ . '" does not exist'; } $buf = Abstract_Session::load($group_); if (!$buf) { return 'Session "' . $group_ . '" does not exist'; } break; case 'UserGroupSharedFolder': $sharedfolderdb = SharedFolderDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($element_); if (!is_object($buf)) { return 'UserGroup "' . $element_ . '" does not exist'; } $buf = $sharedfolderdb->import($group_); if (!$buf) { return 'SharedFolder "' . $group_ . '" does not exist'; } break; case 'UserProfile': $profiledb = ProfileDB::getInstance(); $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $buf = $profiledb->import($group_); if (!$buf) { return 'Profile "' . $group_ . '" does not exist'; } break; case 'UsersGroup': $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($group_); if (!is_object($buf)) { return 'UserGroup "' . $group_ . '" does not exist'; } break; case 'UsersGroupApplicationsGroup': $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($element_); if (!is_object($buf)) { return 'UserGroup "' . $element_ . '" does not exist'; } $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $buf = $applicationsGroupDB->import($group_); if (!is_object($buf)) { return 'ApplicationsGroup "' . $group_ . '" does not exist'; } break; case 'UsersGroupCached': $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($group_); if (!is_object($buf)) { return 'UserGroup "' . $group_ . '" does not exist'; } break; } return true; }
public function session_simulate($user_login_) { $this->check_authorized('viewSummary'); $userDB = UserDB::getInstance(); $user = $userDB->import($user_login_); if (!$user) { return null; } $userGroupDB = UserGroupDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); try { $sessionmanagement = SessionManagement::getInstance(); } catch (Exception $err) { die_error('Unable to instanciate SessionManagement: ' . $err->getMessage(), __FILE__, __LINE__); } $info = array(); // Should only request SessionManagement instance to catch all these information ... $info['settings'] = $user->getSessionSettings('session_settings_defaults'); $search_limit = $this->prefs->get('general', 'max_items_per_page'); $usergroupDB = UserGroupDB::getInstance(); list($groups, $sizelimit_exceeded) = $usergroupDB->getGroupsContains('', array(), $search_limit, $user); $info['user_grps'] = array(); $info['groups_partial_list'] = $sizelimit_exceeded; foreach ($groups as $group_id => $group) { $info['user_grps'][$group_id] = $group->name; } $info['apps_grps'] = array(); $apps_grps = $user->appsGroups(); foreach ($apps_grps as $agrp_id) { $agrp = $applicationsGroupDB->import($agrp_id); if (!is_object($agrp)) { continue; } $info['apps_grps'][$agrp_id] = $agrp->name; } $info['apps'] = array(); $applications = $user->applications(); foreach ($applications as $application) { $a = array('id' => $application->getAttribute('id'), 'name' => $application->getAttribute('name'), 'type' => $application->getAttribute('type')); $info['apps'][$a['id']] = $a; } $info['shared_folders'] = array(); if (array_key_exists('enable_sharedfolders', $info['settings']) && $info['settings']['enable_sharedfolders'] == 1) { $shared_folders = $user->getSharedFolders(); foreach ($shared_folders as $shared_folder_id => $infos) { $info['shared_folders'][$shared_folder_id] = array('share_name' => $infos['share']->name, 'mode' => $infos['mode']); } } $info['profiles'] = array(); if (array_key_exists('enable_profiles', $info['settings']) && $info['settings']['enable_profiles'] == 1) { $profiles = $user->getProfiles(); foreach ($profiles as $profile) { $info['profiles'][$profile->id] = $profile->id; } } $can_start_session = $user->can_use_session(); $remote_desktop_settings = $user->getSessionSettings('remote_desktop_settings'); $remote_desktop_enabled = $remote_desktop_settings['enabled'] == 1; $remote_applications_settings = $user->getSessionSettings('remote_applications_settings'); $remote_applications_enabled = $remote_applications_settings['enabled'] == 1; $bypass_servers_restrictions = $info['settings']['bypass_servers_restrictions'] == 1; $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $info['can_start_session_desktop'] = $can_start_session && $remote_desktop_enabled && $sessionmanagement2->getDesktopServer($bypass_servers_restrictions) && $sessionmanagement2->buildServersList(true); $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $info['can_start_session_applications'] = $can_start_session && $remote_applications_enabled && $sessionmanagement2->buildServersList(true); if ($info['can_start_session_desktop'] || $info['can_start_session_applications']) { $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $servers = $sessionmanagement2->chooseApplicationServers($bypass_servers_restrictions); $info['servers'] = array(); if (is_array($servers)) { foreach ($servers as $server) { $s = array('id' => $server->id, 'name' => $server->getDisplayName(), 'type' => $server->getAttribute('type')); $info['servers'][$s['id']] = $s; } } } if (!$info['can_start_session_desktop'] || !$info['can_start_session_applications']) { if (!$can_start_session) { $info['cannot_start_session_reason'] = 'time_restriction'; } else { if (!$remote_desktop_enabled || !$remote_applications_enabled) { $info['cannot_start_session_reason'] = 'unauthorized_session_mode'; } else { $info['cannot_start_session_reason'] = 'invalid_publications'; } } } return $info; }
public function getGroupsContains($contains_, $attributes_ = array('name', 'description'), $limit_ = 0) { $groups = array(); $userDBAD = UserDB::getInstance(); if (method_exists($userDBAD, 'makeLDAPconfig') === false) { Logger::error('main', 'UserGroupDB::ldap_memberof makeLDAPconfig is not avalaible'); return NULL; } $config_ldap = $userDBAD->makeLDAPconfig(); $config_ldap['match'] = array(); if (array_key_exists('match', $this->preferences)) { $config_ldap['match'] = $this->preferences['match']; } $ldap = new LDAP($config_ldap); $contains = '*'; if ($contains_ != '') { $contains .= $contains_ . '*'; } $filter = '(&(objectClass=group)(|'; foreach ($attributes_ as $attribute) { $filter .= '(' . $config_ldap['match'][$attribute] . '=' . $contains . ')'; } $filter .= '))'; $sr = $ldap->search($filter, NULL, $limit_); if ($sr === false) { Logger::error('main', 'UserDB::ldap::getUsersContaint search failed'); return NULL; } $sizelimit_exceeded = $ldap->errno() === 4; // LDAP_SIZELIMIT_EXCEEDED => 0x04 $infos = $ldap->get_entries($sr); foreach ($infos as $dn => $info) { $buf = array(); foreach ($config_ldap['match'] as $attribut => $match_ldap) { if (isset($info[$match_ldap][0])) { $buf[$attribut] = $info[$match_ldap][0]; } if (isset($info[$match_ldap]) && is_array($info[$match_ldap])) { if (isset($info[$match_ldap]['count'])) { unset($info[$match_ldap]['count']); } $extras[$attribut] = $info[$match_ldap]; } else { $extras[$attribut] = array(); } } if (!isset($buf['description'])) { $buf['description'] = ''; } $ug = new UsersGroup($dn, $buf['name'], $buf['description'], true); $ug->extras = $extras; $groups[$dn] = $ug; } return array($groups, $sizelimit_exceeded); }
public function getGroupsContains($contains_, $attributes_ = array('name', 'description'), $limit_ = 0, $user_ = null) { $groups = array(); $filters = array($this->preferences['filter']); if ($contains_ != '') { $contains = preg_replace('/\\*\\*+/', '*', '*' . $contains_ . '*'); // ldap does not handle multiple star characters $filter_contain_rules = array(); $missing_attribute_nb = 0; foreach ($attributes_ as $attribute) { if (!array_key_exists($attribute, $this->preferences['match']) || strlen($this->preferences['match'][$attribute]) == 0) { $missing_attribute_nb++; continue; } array_push($filter_contain_rules, $this->preferences['match'][$attribute] . '=' . $contains); } if ($missing_attribute_nb == count($attributes_)) { return array(array(), false); } array_push($filters, LDAP::join_filters($filter_contain_rules, '|')); } $sizelimit_exceeded_user = false; if (!is_null($user_)) { if (in_array('group_field', $this->preferences['group_match_user'])) { if ($this->preferences['group_field_type'] == 'user_dn') { $value = $user_->getAttribute('dn'); } else { $value = $user_->getAttribute('login'); } $filter_user = $this->preferences['group_field'] . '=' . $value; } else { $field = $this->preferences['user_field']; $userDB = UserDB::getInstance(); $configLDAP = $userDB->config; $ldap = new LDAP($configLDAP); $sr = $ldap->searchDN($user_->getAttribute('dn'), array($field)); if ($sr === false) { Logger::error('main', 'UserGroupDB::ldapimport_by_user ldap failed (mostly timeout on server)'); return array(); } $infos = $ldap->get_entries($sr); if (!is_array($infos) || $infos === array()) { return array(); } $keys = array_keys($infos); $dn = $keys[0]; $info = $infos[$dn]; if (is_array($info[$field])) { if (isset($info[$field]['count'])) { unset($info[$field]['count']); } $memberof = $info[$field]; } else { $memberof = array($info[$field]); } while (count($memberof) > $limit_) { $sizelimit_exceeded_user = true; array_pop($memberof); } $filter_user_rules = array(); if ($this->preferences['user_field_type'] == 'group_dn') { foreach ($memberof as $dn) { list($rdn, $sub) = explode_with_escape(',', $dn, 2); array_push($filter_user_rules, '(' . $rdn . ')'); } } else { $filters = array(); foreach ($memberof as $name) { array_push($filter_user_rules, '(' . $this->preferences['match']['name'] . '=' . $name . ')'); } } $filter_user = LDAP::join_filters($filter_user_rules, '|'); } array_push($filters, $filter_user); } $filter = LDAP::join_filters($filters, '&'); $ldap = new LDAP($this->get_usergroup_ldap_config()); $sr = $ldap->search($filter, array_values($this->preferences['match']), $limit_); if ($sr === false) { Logger::error('main', 'UsersGroupDB::ldap::getUsersContaint search failed'); return array(array(), false); } $sizelimit_exceeded = $ldap->errno() === 4; // LDAP_SIZELIMIT_EXCEEDED => 0x04 $infos = $ldap->get_entries($sr); foreach ($infos as $dn => $info) { if (!is_null($user_) && isset($memberof)) { if (!in_array($dn, $memberof)) { continue; } } $ug = $this->generateUsersGroupFromRow($info, $dn, $this->preferences['match']); $groups[$dn] = $ug; } return array($groups, $sizelimit_exceeded_user or $sizelimit_exceeded); }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_ldap_memberof::loadGroups ({$type_},{$element_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $element_user = $userDB->import($element_); if (!is_object($element_user)) { Logger::error('main', "Abstract_Liaison_ldap_memberof::loadGroups load element ({$element_}) failed"); return NULL; } if ($element_user->hasAttribute('memberof')) { $groups = array(); $memberof = $element_user->getAttribute('memberof'); if (is_string($memberof)) { $memberof = array($memberof); } foreach ($memberof as $id_group) { $g = $userGroupDB->import($id_group); if (is_object($g)) { $l = new Liaison($element_, $g->getUniqueID()); $groups[$l->group] = $l; } } return $groups; } Logger::error('main', "Abstract_Liaison_ldap_memberof::loadGroups ({$type_},{$element_}) end of function"); return NULL; }
public static function loadUnique($type_, $element_, $group_) { Logger::debug('main', "Abstract_Liaison_dynamic::loadUnique ({$type_},{$element_},{$group_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $group = $userGroupDB->import($group_); if (!is_object($group)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique load group ({$group_}) failed"); return NULL; } $user = $userDB->import($element_); if (!is_object($user)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique load {$element} ({$element_}) failed"); return NULL; } if (!$group->containUser($user)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique({$type_},{$element_},{$group_}) group does not contain the user"); return NULL; } else { return new Liaison($user->getAttribute('login'), $group_); } }
public function getList($sort_ = false) { Logger::debug('main', 'UserGroupDB::activedirectory::getList'); $userDBAD = UserDB::getInstance(); $config_ldap = $userDBAD->makeLDAPconfig(); $config_ldap['match'] = array(); if (array_key_exists('match', $this->preferences)) { $config_ldap['match'] = $this->preferences['match']; } $ldap = new LDAP($config_ldap); $sr = $ldap->search('(objectClass=group)', array_values($config_ldap['match'])); if ($sr === false) { Logger::error('main', "UserGroupDB::activedirectory::getList search failed"); return NULL; } $infos = $ldap->get_entries($sr); $groups = array(); foreach ($infos as $dn => $info) { $buf = array(); foreach ($config_ldap['match'] as $attribut => $match_ldap) { if (isset($info[$match_ldap][0])) { $buf[$attribut] = $info[$match_ldap][0]; } if (isset($info[$match_ldap]) && is_array($info[$match_ldap])) { if (isset($info[$match_ldap]['count'])) { unset($info[$match_ldap]['count']); } $extras[$attribut] = $info[$match_ldap]; } else { $extras[$attribut] = array(); } } if (!isset($buf['description'])) { $buf['description'] = ''; } if (!isset($buf['name'])) { $buf['name'] = $dn; } $ug = new UsersGroup($dn, $buf['name'], $buf['description'], true); $ug->extras = $extras; $groups[$dn] = $ug; } if ($sort_) { usort($groups, "usergroup_cmp"); } return $groups; }