/** * convert binary id to plain text id * * @param string $accountId * @return string */ protected function _decodeAccountId($accountId) { switch ($this->_userUUIDAttribute) { case 'objectguid': return Tinebase_Ldap::decodeGuid($accountId); break; case 'objectsid': return Tinebase_Ldap::decodeSid($accountId); break; default: return $accountId; break; } }
/** * convert binary id to plain text id * * @param string $groupId * @return string */ protected function _decodeGroupId($groupId) { switch ($this->_groupUUIDAttribute) { case 'objectguid': return Tinebase_Ldap::decodeGuid($groupId); break; case 'objectsid': return Tinebase_Ldap::decodeSid($groupId); break; default: return $groupId; break; } }
/** * read ldap / get users and groups from tine an create mapping * * @return array */ protected function _getGroupMapping() { $this->_logger->info(__METHOD__ . '::' . __LINE__ . ' Fetching user mapping ...'); $filter = Zend_Ldap_Filter::andFilter(Zend_Ldap_Filter::string($this->_groupBaseFilter)); $mapping = array(); $groupNameMapping = $this->_config->groupNameMapping ? $this->_config->groupNameMapping->toArray() : array(); $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Group name mapping: ' . print_r($groupNameMapping, TRUE)); $ldapGroups = $this->_ldap->search($filter, $this->_config->ldap->baseDn, $this->_groupSearchScope, array('*', '+')); foreach ($ldapGroups as $group) { $groupname = isset($groupNameMapping[$group['cn'][0]]) ? $groupNameMapping[$group['cn'][0]] : $group['cn'][0]; $ldapUuid = $this->_uuidProperty === 'objectguid' ? Tinebase_Ldap::decodeGuid($group['objectguid'][0]) : $group[$this->_uuidProperty][0]; try { $tineGroup = $this->_tineGroupBackend->getGroupByName($groupname); $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Group ' . $groupname . ' (' . $group['cn'][0] . '): ' . $tineGroup->getId() . ' -> ' . $ldapUuid); $mapping[$tineGroup->getId()] = $ldapUuid; } catch (Tinebase_Exception_Record_NotDefined $tenf) { // @todo should be: Tinebase_Exception_NotFound $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Group ' . $groupname . ' (' . $group['cn'][0] . '): ' . $tenf->getMessage()); } } $this->_logger->info(__METHOD__ . '::' . __LINE__ . ' Found ' . count($mapping) . ' groups for the mapping.'); $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($mapping, TRUE)); return $mapping; }