/**
  * Handle ldap as data source
  * @param Auth $auth
  * @param string $ext_account
  */
 protected function handleLDAPDataSource($a_auth, $ext_account)
 {
     include_once './Services/LDAP/classes/class.ilLDAPServer.php';
     $server = ilLDAPServer::getInstanceByServerId(ilLDAPServer::getDataSource(AUTH_RADIUS));
     $GLOBALS['ilLog']->write(__METHOD__ . 'Using ldap data source');
     include_once './Services/LDAP/classes/class.ilLDAPUserSynchronisation.php';
     $sync = new ilLDAPUserSynchronisation('radius', $server->getServerId());
     $sync->setExternalAccount($ext_account);
     $sync->setUserData(array());
     $sync->forceCreation($this->force_creation);
     try {
         $internal_account = $sync->sync();
     } catch (UnexpectedValueException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Login failed with message: ' . $e->getMessage());
         $a_auth->status = AUTH_WRONG_LOGIN;
         $a_auth->logout();
         return false;
     } catch (ilLDAPSynchronisationForbiddenException $e) {
         // No syncronisation allowed => create Error
         $GLOBALS['ilLog']->write(__METHOD__ . ': Login failed with message: ' . $e->getMessage());
         $a_auth->status = AUTH_RADIUS_NO_ILIAS_USER;
         $a_auth->logout();
         return false;
     } catch (ilLDAPAccountMigrationRequiredException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Starting account migration.');
         $a_auth->logout();
         ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
     }
     $a_auth->setAuth($internal_account);
     return true;
 }
Ejemplo n.º 2
0
 /** 
  * Called from fetchData after successful login.
  *
  * @param string username
  */
 public function loginObserver($a_username, $a_auth)
 {
     global $ilLog;
     $user_data = array_change_key_case($a_auth->getAuthData(), CASE_LOWER);
     $a_username = $this->extractUserName($user_data);
     include_once './Services/LDAP/classes/class.ilLDAPUserSynchronisation.php';
     $sync = new ilLDAPUserSynchronisation('ldap', $this->server->getServerId());
     $sync->setExternalAccount($a_username);
     $sync->setUserData($user_data);
     $sync->forceCreation(self::$force_creation);
     try {
         $internal_account = $sync->sync();
     } catch (UnexpectedValueException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Login failed with message: ' . $e->getMessage());
         $a_auth->status = AUTH_WRONG_LOGIN;
         $a_auth->logout();
         return false;
     } catch (ilLDAPSynchronisationForbiddenException $e) {
         // No syncronisation allowed => create Error
         $GLOBALS['ilLog']->write(__METHOD__ . ': Login failed with message: ' . $e->getMessage());
         $a_auth->status = AUTH_LDAP_NO_ILIAS_USER;
         $a_auth->logout();
         return false;
     } catch (ilLDAPAccountMigrationRequiredException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Starting account migration.');
         $a_auth->logout();
         ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
     }
     $a_auth->setAuth($internal_account);
     return true;
 }