コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: start.php プロジェクト: bloveing/openulteo
            throw_response(UNAUTHORIZED);
        }
        break;
    case Session::MODE_APPLICATIONS:
        if (!isset($remote_applications_enabled) || $remote_applications_enabled === false) {
            throw_response(UNAUTHORIZED);
        }
        break;
    default:
        throw_response(UNAUTHORIZED);
        break;
}
Logger::debug('main', '(client/start) Now checking for old session');
$ev = new SessionStart(array('user' => $user));
$createNow = true;
$sessions = Abstract_Session::getByUser($user->getAttribute('login'));
if ($sessions > 0) {
    $stop = false;
    foreach ($sessions as $session) {
        switch ($session->status) {
            case Session::SESSION_STATUS_CREATING:
            case Session::SESSION_STATUS_CREATED:
            case Session::SESSION_STATUS_INIT:
            case Session::SESSION_STATUS_READY:
            case Session::SESSION_STATUS_INACTIVE:
                break;
            case Session::SESSION_STATUS_ACTIVE:
                if (!$followme) {
                    Logger::error('main', '(client/start) User \'' . $user->getAttribute('login') . '\' is not authorized to use followme feature');
                    throw_response(USER_WITH_ACTIVE_SESSION);
                }
コード例 #3
0
ファイル: actions.php プロジェクト: skdong/nfs-ovd
     if ($u->hasAttribute('password') && $u->getAttribute('password') === '') {
         popup_error(_('Unable to create user with an empty password'));
         redirect();
     }
     $res = $userDB->add($u);
     if (!$res) {
         popup_error(sprintf(_("Unable to create user '%s'"), $_REQUEST['login']));
         redirect();
     }
     popup_info(sprintf(_("User '%s' successfully added"), $u->getAttribute('login')));
     redirect('users.php');
 }
 if ($_REQUEST['action'] == 'del') {
     if (isset($_REQUEST['checked_users']) && is_array($_REQUEST['checked_users'])) {
         foreach ($_REQUEST['checked_users'] as $user_login) {
             $sessions = Abstract_Session::getByUser($user_login);
             $has_sessions = count($sessions);
             if ($has_sessions) {
                 popup_error(sprintf(_("Unable to delete user '%s' because he has an active session"), $user_login));
             } else {
                 $u = $userDB->import($user_login);
                 if (!is_object($u)) {
                     popup_error(sprintf(_("Unable to delete user '%s'"), $user_login));
                     redirect();
                 }
                 if (Preferences::moduleIsEnabled('ProfileDB')) {
                     $profiledb = ProfileDB::getInstance();
                     $netfolders = $u->getProfiles();
                     if (is_array($netfolders)) {
                         foreach ($netfolders as $netfolder) {
                             $profiledb->remove($netfolder->id);
コード例 #4
0
ファイル: users.php プロジェクト: skdong/nfs-ovd
function show_manage($login, $userDB, $userGroupDB)
{
    $u = $userDB->import($login);
    if (!is_object($u)) {
        die_error('Unable to import user "' . $login . '"', __FILE__, __LINE__);
    }
    $userdb_rw = $userDB->isWriteable();
    $usergroupdb_rw = $userGroupDB->isWriteable();
    $keys = array();
    foreach ($u->getAttributesList() as $attr) {
        if (!in_array($attr, array('login', 'displayname'))) {
            $keys[] = $attr;
        }
    }
    // Users Group
    $groups_mine = $u->usersGroups();
    if (is_null($groups_mine)) {
        die_error(_('Error while requesting usergroups'), __FILE__, __LINE__);
    }
    usort($groups_mine, 'usergroup_cmp');
    $groups_all = $userGroupDB->getList(true);
    $groups_available = array();
    foreach ($groups_all as $group) {
        if (!in_array($group, $groups_mine)) {
            $groups_available[] = $group;
        }
    }
    // Sessions
    $sessions = Abstract_Session::getByUser($login);
    $has_sessions = count($sessions);
    $can_manage_users = isAuthorized('manageUsers');
    $can_manage_usersgroups = isAuthorized('manageUsersGroups');
    page_header();
    echo '<div id="users_div">';
    echo '<h1>' . $u->getAttribute('displayname') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">';
    echo '<tr class="title">';
    echo '<th>' . _('Login') . '</th>';
    foreach ($keys as $key) {
        if ($key != 'password') {
            echo '<th>' . $key . '</th>';
        }
    }
    echo '<th>' . _('Locale') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $u->getAttribute('login') . '</td>';
    foreach ($keys as $key) {
        if ($key != 'password') {
            if (is_array($u->getAttribute($key))) {
                $buf = implode(", ", $u->getAttribute($key));
            } else {
                $buf = $u->getAttribute($key);
            }
            echo '<td>' . $buf . '</td>';
        }
    }
    echo '<td>' . $u->getLocale() . '</td>';
    echo '</tr>';
    echo '</table>';
    if ($userdb_rw and $can_manage_users) {
        echo '<div>';
        echo '<h2>' . _('Settings') . '</h2>';
        echo '<div>';
        echo '<form action="actions.php" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user?') . '\');">';
        echo '<input type="submit" value="' . _('Delete this user') . '"/>';
        echo '<input type="hidden" name="name" value="User" />';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="checked_users[]" value="' . htmlspecialchars($login) . '" />';
        echo '</form>';
        echo '</div>';
        echo '<br/><br/>';
        echo '<div>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="User" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="id" value="' . htmlspecialchars($login) . '" />';
        echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">';
        $count = 0;
        $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
        echo '<tr class="' . $content . '">';
        echo '<th>' . _('Display name') . '</th>';
        echo '<td><input type="text" name="displayname" value="' . htmlspecialchars($u->getAttribute('displayname')) . '" /></td>';
        echo '</tr>';
        if ($u->hasAttribute('password')) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            echo '<tr class="' . $content . '">';
            echo '<th>' . _('New password') . '</th>';
            echo '<td><input type="password" name="password" value="" /></td>';
            echo '</tr>';
        }
        foreach ($keys as $key) {
            if ($key == 'password') {
                continue;
            }
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            echo '<tr class="' . $content . '">';
            echo '<th>' . $key . '</th>';
            echo '<td><input type="text" name="' . $key . '" value="' . $u->getAttribute($key) . '" /></td>';
            echo '</tr>';
        }
        $content = 'content' . ($count % 2 == 0 ? 1 : 2);
        echo '<tr class="' . $content . '">';
        echo '<td colspan="2">';
        echo '<input type="submit" name="modify" value="' . _('Save changes') . '" />';
        echo '</td>';
        echo '</tr>';
        echo '</table>';
        echo '</form>';
        echo '</div>';
    }
    // User groups part
    if (count($groups_all) > 0) {
        echo '<div>';
        echo '<h2>' . _('User groups with this user') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($groups_mine as $group) {
            echo '<tr><td>';
            if ($can_manage_usersgroups) {
                echo '<a href="usersgroup.php?action=manage&id=' . $group->getUniqueID() . '">' . $group->name . '</a>';
            } else {
                echo $group->name;
            }
            echo '</td>';
            if ($usergroupdb_rw and $can_manage_usersgroups and $group->isDefault() == false) {
                echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user from this group?') . '\');">';
                echo '<input type="hidden" name="name" value="User_UserGroup" />';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="group" value="' . $group->getUniqueID() . '" />';
                echo '<input type="hidden" name="element" value="' . htmlspecialchars($login) . '" />';
                echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                echo '</form></td>';
            }
            echo '</tr>';
        }
        if (count($groups_available) > 0 && $usergroupdb_rw 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="element" value="' . htmlspecialchars($login) . '" />';
            echo '<select name="group">';
            foreach ($groups_available as $group) {
                echo '<option value="' . $group->getUniqueID() . '" >' . $group->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form></tr>';
        }
        echo '</table>';
        echo "</div>\n";
    }
    $apps_s = $u->applications();
    if (is_array($apps_s) && count($apps_s) > 0) {
        echo '<br />';
        echo '<h2>' . _('Published applications') . '</h2>';
        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 '</tr>';
        }
        echo '</table>';
    }
    if ($has_sessions) {
        echo '<div>';
        echo '<h2>' . _('Active sessions') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($sessions as $session) {
            echo '<form action="sessions.php"><tr>';
            echo '<td>';
            $buf = $session->getAttribute('start_time');
            if (!$buf) {
                echo _('Not started yet');
            } else {
                echo @date('d/m/Y H:i:s', $session->getAttribute('start_time'));
            }
            echo '</td>';
            echo '<td><a href="servers.php?action=manage&fqdn=' . $session->server . '">' . $session->server . '</td>';
            echo '<td>';
            echo '<input type="hidden" name="info" value="' . $session->id . '" />';
            echo '</td><td><input type="submit" value="' . _('Information about this session') . '" /></td>';
            echo '</td>';
            echo '</tr></form>';
        }
        echo '</table>';
        echo '</div>';
    }
    echo '</div>';
    page_footer();
    die;
}
コード例 #5
0
ファイル: api.php プロジェクト: bloveing/openulteo
 public function user_remove($login_)
 {
     $this->check_authorized('manageUsers');
     $userDB = UserDB::getInstance();
     if (!$userDB->isWriteable()) {
         Logger::error('api', 'UserDB is not writable');
         return false;
     }
     $user = $userDB->import($login_);
     if (!is_object($user)) {
         Logger::error('api', sprintf('Unknown application "%s"', $login_));
         return false;
     }
     $sessions = Abstract_Session::getByUser($login_);
     if (count($sessions) > 0) {
         Logger::error('api', sprintf('Unable to delete user "%s" because he has an active session', $login_));
         return false;
     }
     if (Preferences::moduleIsEnabled('ProfileDB')) {
         $netfolders = $user->getProfiles();
         if (is_array($netfolders)) {
             $profiledb = ProfileDB::getInstance();
             foreach ($netfolders as $netfolder) {
                 $profiledb->remove($netfolder->id);
                 $server = Abstract_Server::load($netfolder->server);
                 if ($profiledb->isInternal()) {
                     $server->deleteNetworkFolder($netfolder->id, true);
                 }
             }
         }
     }
     $res = $userDB->remove($user);
     if (!$res) {
         return false;
     }
     $this->log_action('user_remove', array('login' => $login_));
     return true;
 }