/** * remove one groupmember from the group * * @param int $_groupId * @param int $_accountId * @return unknown */ public function removeGroupMember($_groupId, $_accountId) { $dn = $this->_getDn($_groupId); $memberUidNumbers = $this->getGroupMembers($_groupId); $accountMetaData = $this->_getAccountMetaData($_accountId); if (!in_array($accountMetaData['uidNumber'], $memberUidNumbers)) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " skipp removing group member, as {$accountMetaData['uid']} is not in group {$dn}"); } return; } $data = array('memberuid' => $accountMetaData['uid']); if ($this->_options['useRfc2307bis']) { if (count($memberUidNumbers) > 1) { $data['member'] = $accountMetaData['dn']; } else { // deleting last member is handled by $this->_saveRfc2307GroupMembers unset($memberUidNumbers[$accountMetaData['uidNumber']]); $this->_saveRfc2307GroupMembers($_groupId, $memberUidNumbers); return; } } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $dn: ' . $dn); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $data: ' . print_r($data, true)); } $this->_ldap->deleteProperty($dn, $data); }
/** * remove one member from the group in sync backend * * @param mixed $_groupId * @param mixed $_accountId */ public function removeGroupMemberInSyncBackend($_groupId, $_accountId) { if ($this->_isReadOnlyBackend) { return; } $userId = Tinebase_Model_User::convertUserIdToInt($_accountId); $groupId = Tinebase_Model_Group::convertGroupIdToInt($_groupId); $memberships = $this->getGroupMemberships($_accountId); if (!in_array($groupId, $memberships)) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " skip removing group member, as {$userId} is not in group {$groupId} " . print_r($memberships, true)); } return; } try { $groupDn = $this->_getDn($_groupId); } catch (Tinebase_Exception_NotFound $tenf) { if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) { Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . " Failed to remove groupmember {$_accountId} from group {$_groupId}: " . $tenf->getMessage()); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $tenf->getTraceAsString()); } return; } try { $accountMetaData = $this->_getAccountMetaData($_accountId); } catch (Tinebase_Exception_NotFound $tenf) { if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) { Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' user not found in sync backend: ' . $_accountId); } return; } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " account meta data: " . print_r($accountMetaData, true)); } $memberUidNumbers = $this->getGroupMembers($_groupId); $ldapData = array('memberuid' => $accountMetaData['uid']); if (isset($this->_options['useRfc2307bis']) && $this->_options['useRfc2307bis']) { if (count($memberUidNumbers) === 1) { // we need to add the group dn, as the member attribute is not allowed to be empty $dataAdd = array('member' => $groupDn); $this->_ldap->insertProperty($groupDn, $dataAdd); } else { $ldapData['member'] = $accountMetaData['dn']; } } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $dn: ' . $groupDn); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' $ldapData: ' . print_r($ldapData, true)); } try { $this->_ldap->deleteProperty($groupDn, $ldapData); } catch (Zend_Ldap_Exception $zle) { if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) { Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . " Failed to remove groupmember {$accountMetaData['dn']} from group {$groupDn}: " . $zle->getMessage()); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $zle->getTraceAsString()); } } }