Example #1
0
 /**
  * Gets all entries
  *
  * @param string $_orderBy Order result by
  * @param string $_orderDirection Order direction - allowed are ASC and DESC
  * @throws Tinebase_Exception_InvalidArgument
  * @return Tinebase_Record_RecordSet
  */
 public function getAll($_orderBy = 'id', $_orderDirection = 'ASC')
 {
     if (!in_array($_orderBy, $this->_getSupportedRecordFields())) {
         throw new Tinebase_Exception_InvalidArgument('$_orderBy field "' . $_orderBy . '" is not supported by this backend instance');
     }
     $rawLdapData = $this->_ldap->fetchAll($this->_baseDn, 'objectclass=inetorgperson', $this->_getSupportedLdapAttributes());
     $contacts = $this->_ldap2Contacts($rawLdapData);
     $contacts->sort($_orderBy, $_orderDirection);
     return $contacts;
 }
Example #2
0
 /**
  * generates a gidnumber
  *
  * @todo add a persistent registry which id has been generated lastly to
  *       reduce amount of groupid to be transfered
  * 
  * @return int
  */
 protected function _generateGidNumber()
 {
     $allGidNumbers = array();
     foreach ($this->_ldap->fetchAll($this->_options['groupsDn'], 'objectclass=posixgroup', array('gidnumber')) as $groupData) {
         $allGidNumbers[] = $groupData['gidnumber'][0];
     }
     sort($allGidNumbers);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . "  Existing gidnumbers " . print_r($allGidNumbers, true));
     }
     $numGroups = count($allGidNumbers);
     if ($numGroups == 0 || $allGidNumbers[$numGroups - 1] < $this->_options['minGroupId']) {
         $gidNumber = $this->_options['minGroupId'];
     } elseif ($allGidNumbers[$numGroups - 1] < $this->_options['maxGroupId']) {
         $gidNumber = ++$allGidNumbers[$numGroups - 1];
     } else {
         throw new Tinebase_Exception_NotImplemented('Max Group Id is reached');
     }
     return $gidNumber;
 }
Example #3
0
 /**
  * generates a uidnumber
  *
  * @todo add a persistent registry which id has been generated lastly to
  *       reduce amount of userid to be transfered
  * 
  * @return int
  */
 protected function _generateUidNumber()
 {
     $allUidNumbers = array();
     foreach ($this->_backend->fetchAll($this->_options['userDn'], 'objectclass=posixAccount', array('uidnumber')) as $userData) {
         $allUidNumbers[] = $userData['uidnumber'][0];
     }
     sort($allUidNumbers);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . "  Existing uidnumbers " . print_r($allUidNumbers, true));
     }
     $numUsers = count($allUidNumbers);
     if ($numUsers == 0 || $allUidNumbers[$numUsers - 1] < $this->_options['minUserId']) {
         $uidNumber = $this->_options['minUserId'];
     } elseif ($allUidNumbers[$numUsers - 1] < $this->_options['maxUserId']) {
         $uidNumber = ++$allUidNumbers[$numUsers - 1];
     } else {
         throw new Tinebase_Exception_NotImplemented('Max User Id is reached');
     }
     return $uidNumber;
 }