/**
  * test if deleted users data is removed
  *
  * @see TODO add mantis issue
  *
  * TODO add test cases for keepOrganizerEvents and $_keepAsContact and $_keepAsContact
  */
 public function testDeleteUsersData()
 {
     // configure removal of data
     Tinebase_Config::getInstance()->set(Tinebase_Config::ACCOUNT_DELETION_EVENTCONFIGURATION, new Tinebase_Config_Struct(array('_deletePersonalContainers' => true)));
     // we need a valid group and a contact for this test
     $userContact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_given' => 'testuser')));
     $testUser = $this->getTestRecord();
     $testUser->contact_id = $userContact->getId();
     $this->_backend->addUser($testUser);
     Tinebase_Group::getInstance()->addGroupMember($testUser->accountPrimaryGroup, $testUser->getId());
     $this->_setUser($testUser);
     // add a contact and an event to personal folders
     $event = Calendar_Controller_Event::getInstance()->create(new Calendar_Model_Event(array('summary' => 'testevent', 'dtstart' => '2015-12-24 12:00:00', 'dtend' => '2015-12-24 13:00:00'), true));
     $contact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_given' => 'testcontact')));
     $this->_setUser($this->_originalTestUser);
     $this->_backend->deleteUser($testUser);
     // check if contact and event are removed
     $adbBackend = new Addressbook_Backend_Sql();
     try {
         $adbBackend->get($contact->getId());
         $this->fail('contact be deleted');
     } catch (Exception $e) {
         $this->assertTrue($e instanceof Tinebase_Exception_NotFound);
     }
     $calBackend = new Calendar_Backend_Sql();
     try {
         $calBackend->get($event->getId());
         $this->fail('event should be deleted: ' . print_r($event->toArray(), true));
     } catch (Exception $e) {
         $this->assertTrue($e instanceof Tinebase_Exception_NotFound);
     }
 }
 /**
  * try to delete an accout
  *
  */
 public function testDeleteUser()
 {
     // add a test user (enabled by default)
     $testUser = $this->testAddUser();
     $this->_backend->deleteUser($testUser);
     unset($this->objects['users']['addedUser']);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $this->_backend->getUserById($testUser, 'Tinebase_Model_FullUser');
 }
 /**
  * Return a single record
  *
  * @param   string $id
  * @return  array record data
  */
 public function getLead($id)
 {
     $organizerIds = array();
     $lead = $this->_get($id, $this->_controller);
     foreach ($lead['relations'] as $relation) {
         if ($relation['related_model'] == 'Tasks_Model_Task') {
             $organizerIds[] = $relation['related_record']['organizer'];
         }
     }
     $be = new Tinebase_User_Sql();
     $organizers = $be->getMultiple($organizerIds);
     for ($i = 0; $i < count($lead['relations']); $i++) {
         if ($lead['relations'][$i]['related_model'] == 'Tasks_Model_Task') {
             $organizer = $organizers->getById($lead['relations'][$i]['related_record']['organizer']);
             if ($organizer) {
                 $lead['relations'][$i]['related_record']['organizer'] = $organizer->toArray();
             }
         }
     }
     return $lead;
 }
Ejemplo n.º 4
0
 /**
  * read ldap / get users from tine an create mapping
  * 
  * @return array
  */
 protected function _getUserMapping()
 {
     $this->_logger->info(__METHOD__ . '::' . __LINE__ . ' Fetching user mapping ...');
     $filter = Zend_Ldap_Filter::andFilter(Zend_Ldap_Filter::string($this->_userBaseFilter));
     $mapping = array();
     $ldapUsers = $this->_ldap->search($filter, $this->_config->ldap->baseDn, $this->_userSearchScope, array('*', '+'));
     foreach ($ldapUsers as $user) {
         $username = $user['uid'][0];
         $ldapUuid = $user['entryuuid'][0];
         try {
             $tineUser = $this->_tineUserBackend->getFullUserByLoginName($username);
             $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' User ' . $username . ': ' . $tineUser->getId() . ' -> ' . $ldapUuid);
             $mapping[$tineUser->getId()] = $ldapUuid;
         } catch (Tinebase_Exception_NotFound $tenf) {
             $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' User ' . $username . ' not found.');
         }
     }
     $this->_logger->info(__METHOD__ . '::' . __LINE__ . ' Found ' . count($mapping) . ' users for the mapping.');
     $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($mapping, TRUE));
     return $mapping;
 }
 /**
  * the constructor
  *
  * @param  array  $_options  Options used in connecting, binding, etc.
  * @throws Tinebase_Exception_Backend_Ldap
  */
 public function __construct(array $_options = array())
 {
     parent::__construct($_options);
     if (empty($_options['userUUIDAttribute'])) {
         $_options['userUUIDAttribute'] = 'entryUUID';
     }
     if (empty($_options['groupUUIDAttribute'])) {
         $_options['groupUUIDAttribute'] = 'entryUUID';
     }
     if (empty($_options['baseDn'])) {
         $_options['baseDn'] = $_options['userDn'];
     }
     if (empty($_options['userFilter'])) {
         $_options['userFilter'] = 'objectclass=posixaccount';
     }
     if (empty($_options['userSearchScope'])) {
         $_options['userSearchScope'] = Zend_Ldap::SEARCH_SCOPE_SUB;
     }
     if (empty($_options['groupFilter'])) {
         $_options['groupFilter'] = 'objectclass=posixgroup';
     }
     if (isset($_options['requiredObjectClass'])) {
         $this->_requiredObjectClass = (array) $_options['requiredObjectClass'];
     }
     if (isset($_options['readonly']) || array_key_exists('readonly', $_options)) {
         $this->_isReadOnlyBackend = (bool) $_options['readonly'];
     }
     if (isset($_options['ldap']) || array_key_exists('ldap', $_options)) {
         $this->_ldap = $_options['ldap'];
     }
     $this->_options = $_options;
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " Registering " . print_r($this->_options, true));
     }
     $this->_userUUIDAttribute = strtolower($this->_options['userUUIDAttribute']);
     $this->_groupUUIDAttribute = strtolower($this->_options['groupUUIDAttribute']);
     $this->_baseDn = $this->_options['baseDn'];
     $this->_userBaseFilter = $this->_options['userFilter'];
     $this->_userSearchScope = $this->_options['userSearchScope'];
     $this->_groupBaseFilter = $this->_options['groupFilter'];
     $this->_rowNameMapping['accountId'] = $this->_userUUIDAttribute;
     if (!$this->_ldap instanceof Tinebase_Ldap) {
         $this->_ldap = new Tinebase_Ldap($this->_options);
         try {
             $this->_ldap->bind();
         } catch (Zend_Ldap_Exception $zle) {
             // @todo move this to Tinebase_Ldap?
             throw new Tinebase_Exception_Backend_Ldap('Could not bind to LDAP: ' . $zle->getMessage());
         }
     }
     foreach ($this->_plugins as $plugin) {
         if ($plugin instanceof Tinebase_User_Plugin_LdapInterface) {
             $this->registerLdapPlugin($plugin);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * construct a typo3 user backend
  */
 public function __construct()
 {
     parent::__construct();
     $this->_t3db = Tinebase_Core::getDb();
     $this->_sqlUserBackend = new Tinebase_User_Sql();
 }
 /**
  * testSavingDuplicateAccount
  * 
  * @see 0006546: saving user with duplicate imap/smtp user entry fails
  */
 public function testSavingDuplicateAccount()
 {
     $user = $this->_addUser();
     $userId = $user->getId();
     // delete user in tine accounts table
     $userBackend = new Tinebase_User_Sql();
     $userBackend->deleteUserInSqlBackend($userId);
     // create user again
     unset($user->accountId);
     $newUser = Tinebase_User::getInstance()->addUser($user);
     $this->_objects['fullUsers'] = array($newUser);
     $this->assertNotEquals($userId, $newUser->getId());
     $this->assertTrue(isset($newUser->imapUser), 'imapUser data not found: ' . print_r($newUser->toArray(), TRUE));
 }
Ejemplo n.º 8
0
 /**
  * the constructor
  *
  * @param  array  $_options  Options used in connecting, binding, etc.
  * @throws Tinebase_Exception_Backend_Ldap
  */
 public function __construct(array $_options = array())
 {
     parent::__construct($_options);
     if (empty($_options['userUUIDAttribute'])) {
         $_options['userUUIDAttribute'] = 'entryUUID';
     }
     if (empty($_options['groupUUIDAttribute'])) {
         $_options['groupUUIDAttribute'] = 'entryUUID';
     }
     if (empty($_options['baseDn'])) {
         $_options['baseDn'] = $_options['userDn'];
     }
     if (empty($_options['userFilter'])) {
         $_options['userFilter'] = 'objectclass=posixaccount';
     }
     if (empty($_options['userSearchScope'])) {
         $_options['userSearchScope'] = Zend_Ldap::SEARCH_SCOPE_SUB;
     }
     if (empty($_options['groupFilter'])) {
         $_options['groupFilter'] = 'objectclass=posixgroup';
     }
     if (isset($_options['requiredObjectClass'])) {
         $this->_requiredObjectClass = (array) $_options['requiredObjectClass'];
     }
     if (array_key_exists('readonly', $_options)) {
         $this->_isReadOnlyBackend = (bool) $_options['readonly'];
     }
     $this->_options = $_options;
     $this->_userUUIDAttribute = strtolower($this->_options['userUUIDAttribute']);
     $this->_groupUUIDAttribute = strtolower($this->_options['groupUUIDAttribute']);
     $this->_baseDn = $this->_options['baseDn'];
     $this->_userBaseFilter = $this->_options['userFilter'];
     $this->_userSearchScope = $this->_options['userSearchScope'];
     $this->_groupBaseFilter = $this->_options['groupFilter'];
     $this->_rowNameMapping['accountId'] = $this->_userUUIDAttribute;
     try {
         $this->_ldap = new Tinebase_Ldap($this->_options);
         $this->_ldap->bind();
     } catch (Zend_Ldap_Exception $zle) {
         // @todo move this to Tinebase_Ldap?
         throw new Tinebase_Exception_Backend_Ldap('Could not bind to LDAP: ' . $zle->getMessage());
     }
     foreach ($this->_plugins as $plugin) {
         if ($plugin instanceof Tinebase_User_Plugin_LdapInterface) {
             $plugin->setLdap($this->_ldap);
             $this->_ldapPlugins[] = $plugin;
         }
     }
 }