Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 4 Aug 2015 16:16:57 +0000 (18:16 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 4 Aug 2015 16:16:57 +0000 (18:16 +0200)
1  2 
tine20/Tinebase/Auth.php
tine20/Tinebase/Ldap.php
tine20/Tinebase/User.php

diff --combined tine20/Tinebase/Auth.php
@@@ -80,7 -80,7 +80,7 @@@ class Tinebase_Aut
      const FAILURE_PASSWORD_EXPIRED      = -101;
      
      /**
 -     * Failure due the account is temporarly blocked
 +     * Failure due the account is temporarily blocked
       */
      const FAILURE_BLOCKED               = -102;
          
              'username' => '',
              'password' => '',
              'bindRequiresDn' => true,
+             'useStartTls' => false,
              'baseDn' => '',
              'accountFilterFormat' => NULL,
              'accountCanonicalForm' => '2',
              'accountDomainName' => '',
              'accountDomainNameShort' => '',
 +            'tryUsernameSplit' => '0'
           ),
           self::IMAP => array(
              'host'      => '',
          if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
              __METHOD__ . '::' . __LINE__ . ' Trying to authenticate '. $_username);
          
 -        $this->_backend->setIdentity($_username);
 +        try {
 +            $this->_backend->setIdentity($_username);
 +        } catch (Zend_Auth_Adapter_Exception $zaae) {
 +            return new Zend_Auth_Result(
 +                Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
 +                $_username,
 +                array($zaae->getMessage())
 +            );
 +        }
 +        
          $this->_backend->setCredential($_password);
          
 -        if (Zend_Session::isStarted()) {
 +        if (Tinebase_Session::isStarted()) {
              Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session());
          } else {
              Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent());
                  $rawBackendConfiguration = array();
              }
              self::$_backendConfiguration = is_array($rawBackendConfiguration) ? $rawBackendConfiguration : Zend_Json::decode($rawBackendConfiguration);
 +            
 +            if (!empty(self::$_backendConfiguration['password'])) {
 +                Tinebase_Core::getLogger()->getFormatter()->addReplacement(self::$_backendConfiguration['password']);
 +            }
          }
 -
 +        
          if (isset($_key)) {
              return (isset(self::$_backendConfiguration[$_key]) || array_key_exists($_key, self::$_backendConfiguration)) ? self::$_backendConfiguration[$_key] : $_default;
          } else {
diff --combined tine20/Tinebase/Ldap.php
@@@ -50,6 -50,9 +50,9 @@@ class Tinebase_Ldap extends Zend_Lda
          ));
          
          $returnValue = parent::__construct($options);
+         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
+             . ' LDAP options: ' . print_r($options, true));
          
          return $returnValue;
      }
       */
      public function getFirstNamingContext()
      {
 -        return array_value(0, $this->getRootDse()->getNamingContexts());
 +        return Tinebase_Helper::array_value(0, $this->getRootDse()->getNamingContexts());
      }
      
      /**
diff --combined tine20/Tinebase/User.php
@@@ -113,6 -113,7 +113,7 @@@ class Tinebase_Use
              'username' => '',
              'password' => '',
              'bindRequiresDn' => true,
+             'useStartTls' => false,
              'useRfc2307bis' => false,
              'userDn' => '',
              'userFilter' => 'objectclass=posixaccount',
                      self::createContactForSyncedUser($currentUser);
                  }
              }
 -        
 +            
 +            Tinebase_Timemachine_ModificationLog::setRecordMetaData($currentUser, 'update');
              $syncedUser = $userBackend->updateUserInSqlBackend($currentUser);
              if (! empty($user->container_id)) {
                  $syncedUser->container_id = $user->container_id;
              if ($user->visibility !== Tinebase_Model_FullUser::VISIBILITY_HIDDEN) {
                  self::createContactForSyncedUser($user);
              }
 +            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
              $syncedUser = $userBackend->addUserInSqlBackend($user);
              $userBackend->addPluginUser($syncedUser, $user);
          }
              if (! $diff->isEmpty()) {
                  // add modlog info
                  Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'update');
 -                Tinebase_Container::getInstance()->increaseContentSequence($contact->container_id);
 +                if ($contact->container_id !== null) {
 +                    Tinebase_Container::getInstance()->increaseContentSequence($contact->container_id);
 +                }
                  
                  if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                      . ' Updating contact data for user ' . $syncedUser->accountLoginName);
          // update or create user in local sql backend
          try {
              $userBackend->getUserByProperty('accountLoginName', $adminLoginName);
 +            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'update');
              $user = $userBackend->updateUserInSqlBackend($user);
          } catch (Tinebase_Exception_NotFound $ten) {
              // call addUser here to make sure, sql user plugins (email, ...) are triggered
 +            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
              $user = $userBackend->addUser($user);
          }
          
          // set the password for the account
 -        Tinebase_User::getInstance()->setPassword($user, $adminPassword);
 +        // empty password triggers password change dialogue during first login
 +        if (!empty($adminPassword)) {
 +            Tinebase_User::getInstance()->setPassword($user, $adminPassword);
 +        }
  
          // add the admin account to all groups
          Tinebase_Group::getInstance()->addGroupMember($adminGroup, $user);