/**
  * test user status sync tine <-> ldap
  *
  * @see 0011554: improve ldap account status handling
  */
 public function testSyncUserStatus()
 {
     $user = $this->testAddUser();
     // set user status in tine (disabled, expired, enabled)
     $statusToTest = array(Tinebase_Model_User::ACCOUNT_STATUS_EXPIRED, Tinebase_Model_User::ACCOUNT_STATUS_DISABLED, Tinebase_Model_User::ACCOUNT_STATUS_EXPIRED, Tinebase_Model_User::ACCOUNT_STATUS_ENABLED);
     foreach ($statusToTest as $status) {
         Tinebase_User::getInstance()->setStatus($user, $status);
         // sync user -> user status should be the same
         $syncedUser = Tinebase_User::syncUser($user, array('syncAccountStatus' => true));
         $this->assertEquals($status, $syncedUser->accountStatus, print_r($syncedUser->toArray(), true));
     }
 }
 /**
  * get login user
  * 
  * @param string $_username
  * @param Tinebase_Model_AccessLog $_accessLog
  * @return Tinebase_Model_FullUser|NULL
  */
 protected function _getLoginUser($_username, Tinebase_Model_AccessLog $_accessLog)
 {
     $accountsController = Tinebase_User::getInstance();
     $user = NULL;
     try {
         // does the user exist in the user database?
         if ($accountsController instanceof Tinebase_User_Interface_SyncAble) {
             /**
              * catch all exceptions during user data sync
              * either it's the first sync and no user data get synchronized or
              * we can work with the data synced during previous login
              */
             try {
                 Tinebase_User::syncUser($_username, array('syncContactData' => TRUE));
             } catch (Exception $e) {
                 Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Failed to sync user data for: ' . $_username . ' reason: ' . $e->getMessage());
                 Tinebase_Exception::log($e);
             }
         }
         $user = $accountsController->getFullUserByLoginName($_username);
         $_accessLog->account_id = $user->getId();
         $_accessLog->login_name = $user->accountLoginName;
     } catch (Tinebase_Exception_NotFound $e) {
         if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) {
             Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Account ' . $_username . ' not found in account storage.');
         }
         $_accessLog->result = Tinebase_Auth::FAILURE_IDENTITY_NOT_FOUND;
     } catch (Zend_Db_Adapter_Exception $zdae) {
         if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) {
             Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Some database connection failed: ' . $zdae->getMessage());
         }
         $_accessLog->result = Tinebase_Auth::FAILURE_DATABASE_CONNECTION;
     }
     return $user;
 }
Пример #3
0
 /**
  * execute Tinebase_User::syncUser
  */
 public function testSyncUser()
 {
     $user = $this->testAddUser();
     Tinebase_User::syncUser($user, Tinebase_Application::getInstance()->isInstalled('Addressbook'));
 }