Ejemplo n.º 1
0
                </label>
            </dt>
            <dd>
                
                <?php 
    if (in_array('authSource', $this->editableFields)) {
        ?>
                
                    <select id="authSourceSelector" name="authSource">
                    
                    <?php 
        $authSourceInOptions = false;
        ?>
                        
                    <?php 
        foreach (AuthDriverManager::getRegisteredDrivers() as $authDriver) {
            ?>
                        
                        <?php 
            if ($authDriver->getAuthSource() == $this->data['authSource']) {
                ?>
                        
                            <option value="<?php 
                echo $authDriver->getAuthSource();
                ?>
" selected="selected">
                                <?php 
                echo $authDriver->getAuthSource();
                ?>
                            </option>
                            
Ejemplo n.º 2
0
 protected static function initDriverList()
 {
     // load static drivers
     self::$drivers = array('claroline' => new ClarolineLocalAuthDriver(), 'disabled' => new UserDisabledAuthDriver(), 'temp' => new TemporaryAccountAuthDriver(), 'CAS' => new ClarolineLocalAuthDriver());
     self::$driversAllowingLostPassword = array('claroline' => 'claroline', 'clarocrypt' => 'clarocrypt');
     // load dynamic drivers
     if (!file_exists(get_path('rootSys') . 'platform/conf/extauth')) {
         FromKernel::uses('fileManage.lib');
         claro_mkdir(get_path('rootSys') . 'platform/conf/extauth', CLARO_FILE_PERMISSIONS, true);
     }
     if (get_conf('claro_authDriversAutoDiscovery', true)) {
         $driversToLoad = array();
         $it = new DirectoryIterator(get_path('rootSys') . 'platform/conf/extauth');
         foreach ($it as $file) {
             if ($file->isFile() && substr($file->getFilename(), -9) == '.conf.php') {
                 $driversToLoad[] = $file->getPathname();
             }
         }
         sort($driversToLoad);
         foreach ($driversToLoad as $driverFile) {
             self::loadDriver($driverFile);
         }
     } else {
         if (file_exists(get_path('rootSys') . 'platform/conf/extauth/drivers.list')) {
             $authDriverList = file(get_path('rootSys') . 'platform/conf/extauth/drivers.list');
             foreach ($authDriverList as $authDriver) {
                 $authDriver = trim($authDriver);
                 if (!empty($authDriver)) {
                     self::loadDriver(ltrim(rtrim(get_path('rootSys') . 'platform/conf/extauth/' . $authDriver)));
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
$extAuthPasswordCount = 0;
$passwordFound = false;
$userAccountList = array();
// Get the forgotten email from the form
if (isset($_REQUEST['Femail'])) {
    $emailTo = strtolower(trim($_REQUEST['Femail']));
} else {
    $emailTo = '';
}
// Main section
if (isset($_REQUEST['searchPassword']) && !empty($emailTo)) {
    // search user with this email
    $sql = "SELECT  `user_id`   `uid`       ,\n                    `nom`       `lastName`  ,\n                    `prenom`    `firstName` ,\n                    `username`  `loginName` ,\n                    `password`              ,\n                    `email`                 ,\n                    `authSource`            ,\n                    `creatorId`\n             FROM `" . $tbl_user . "`\n             WHERE LOWER(email) = '" . claro_sql_escape($emailTo) . "'";
    $userList = claro_sql_query_fetch_all($sql);
    if (count($userList) > 0) {
        $allowedAuthSources = AuthDriverManager::getDriversAllowingLostPassword();
        foreach ($userList as $user) {
            if (isset($allowedAuthSources[$user['authSource']])) {
                $passwordFound = true;
                if (get_conf('userPasswordCrypted', false)) {
                    /*
                     * If password are crypted, we can not send them as such.
                     * We have to generate new ones.
                     */
                    $user['password'] = generate_passwd();
                    // UPDATE THE DB WITH THE NEW GENERATED PASSWORD
                    $sql = 'UPDATE `' . $tbl_user . '`
                            SET   `password` = "' . claro_sql_escape(md5($user['password'])) . '"
                             WHERE `user_id` = "' . $user['uid'] . '"';
                    if (claro_sql_query($sql) === false) {
                        trigger_error('<p align="center">' . get_lang('Wrong operation') . '</p>', E_USER_ERROR);
Ejemplo n.º 4
0
 /**
  * Get the authentication profile for the given user id
  * @param int $userId
  * @return AuthProfile
  */
 public static function getUserAuthProfile($userId)
 {
     if ($userId != claro_get_current_user_id()) {
         $user = new Claro_User($userId);
         $user->loadFromDatabase();
     } else {
         $user = Claro_CurrentUser::getInstance();
     }
     $authSource = $user->authSource;
     if (!$authSource) {
         throw new Exception("Cannot find user authentication source for user {$userId}");
     }
     try {
         $profileOptions = AuthDriverManager::getDriver($authSource)->getAuthProfileOptions();
     } catch (Exception $e) {
         if (claro_is_platform_admin() || claro_is_in_a_course() && claro_is_course_manager() && $userId != claro_get_current_user_id()) {
             Console::warning("Cannot find user authentication source for user {$userId}, use claroline default options instead");
             $profileOptions = AuthDriverManager::getDriver('claroline')->getAuthProfileOptions();
         } else {
             throw $e;
         }
     }
     $authProfile = new AuthProfile($userId, $authSource);
     $authProfile->setAuthDriverOptions($profileOptions);
     if (claro_debug_mode()) {
         pushClaroMessage(var_export($profileOptions, true), 'debug');
     }
     return $authProfile;
 }