/**
  * delete accounts
  *
  * @param   mixed $_accountIds  array of account ids
  * @return  array with success flag
  * @throws  Tinebase_Exception_Record_NotAllowed
  */
 public function delete($_accountIds)
 {
     $this->checkRight('MANAGE_ACCOUNTS');
     $groupsController = Admin_Controller_Group::getInstance();
     foreach ((array) $_accountIds as $accountId) {
         if ($accountId === Tinebase_Core::getUser()->getId()) {
             $message = 'You are not allowed to delete yourself!';
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $message);
             throw new Tinebase_Exception_AccessDenied($message);
         }
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " about to remove user with id: {$accountId}");
         $oldUser = $this->get($accountId);
         $memberships = $groupsController->getGroupMemberships($accountId);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " removing user from groups: " . print_r($memberships, true));
         }
         foreach ((array) $memberships as $groupId) {
             $groupsController->removeGroupMember($groupId, $accountId);
         }
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true && !empty($oldUser->contact_id)) {
             $this->_deleteContact($oldUser->contact_id);
         }
         $this->_userBackend->deleteUser($accountId);
     }
 }
Exemple #2
0
 /**
  * inspect set password
  * 
  * @param string   $_userId
  * @param string   $_password
  * @param boolean  $_encrypt
  * @param boolean  $_mustChange
  * @param array    $_ldapData    the data to be written to ldap
  */
 public function inspectSetPassword($_userId, $_password, $_encrypt, $_mustChange, array &$_ldapData)
 {
     if ($_encrypt !== true) {
         Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' can not transform crypted password into nt/lm samba password. Make sure to reset password for user ' . $_userId);
     } else {
         $_ldapData['sambantpassword'] = Tinebase_User_Abstract::encryptPassword($_password, Tinebase_User_Abstract::ENCRYPT_NTPASSWORD);
         $_ldapData['sambalmpassword'] = array();
         if ($_mustChange === true) {
             $_ldapData['sambapwdmustchange'] = '1';
             $_ldapData['sambapwdcanchange'] = '1';
             $_ldapData['sambapwdlastset'] = array();
         } else {
             if ($_mustChange === false) {
                 $_ldapData['sambapwdmustchange'] = '2147483647';
                 $_ldapData['sambapwdcanchange'] = '1';
                 $_ldapData['sambapwdlastset'] = Tinebase_DateTime::now()->getTimestamp();
             } else {
                 if ($_mustChange === null && $_userId instanceof Tinebase_Model_FullUser && isset($_userId->sambaSAM) && isset($_userId->sambaSAM->pwdMustChange) && isset($_userId->sambaSAM->pwdCanChange)) {
                     $_ldapData['sambapwdmustchange'] = $_userId->sambaSAM->pwdMustChange->getTimestamp();
                     $_ldapData['sambapwdcanchange'] = $_userId->sambaSAM->pwdCanChange->getTimestamp();
                     $_ldapData['sambapwdlastset'] = array();
                 }
             }
         }
     }
 }
Exemple #3
0
 /**
  * the constructor
  *
  * @param  array $options Options used in connecting, binding, etc.
  */
 public function __construct(array $_options = array())
 {
     parent::__construct($_options);
     $this->_db = Tinebase_Core::getDb();
     foreach ($this->_plugins as $plugin) {
         if ($plugin instanceof Tinebase_User_Plugin_SqlInterface) {
             $this->_sqlPlugins[] = $plugin;
         }
     }
 }
Exemple #4
0
 /**
  * set the password for given account
  * 
  * @param   int $_accountId
  * @param   string $_password
  * @param   bool $_encrypt encrypt password
  * @return  void
  * @throws  Tinebase_Exception_InvalidArgument
  */
 public function setPassword($_loginName, $_password, $_encrypt = TRUE)
 {
     if (empty($_loginName)) {
         throw new Tinebase_Exception_InvalidArgument('$_loginName can not be empty');
     }
     $user = $this->getFullUserByLoginName($_loginName);
     $metaData = $this->_getMetaData($user);
     $encryptionType = $this->_options['pwEncType'];
     $userpassword = $_encrypt ? Tinebase_User_Abstract::encryptPassword($_password, $encryptionType) : $_password;
     $ldapData = array('userpassword' => $userpassword, 'shadowlastchange' => Tinebase_DateTime::now()->getTimestamp());
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . '  $dn: ' . $metaData['dn']);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . '  $ldapData: ' . print_r($ldapData, true));
     }
     $this->_backend->update($metaData['dn'], $ldapData);
 }
 protected function _deleteDummyUsers()
 {
     foreach ($this->_objects as $object) {
         $this->_uit->deleteUser($object->getId());
     }
 }
 /**
  * unregisterAllPlugins
  */
 public function unregisterAllPlugins()
 {
     parent::unregisterAllPlugins();
     $this->_sqlPlugins = array();
 }