| | |
| | | } |
| | | if (is_array($this->prop['search_fields'])) { |
| | | foreach ($this->prop['search_fields'] as $field) { |
| | | $filter .= "($field=$wp" . $this->_quote_string($value) . "$ws)"; |
| | | $filter .= "($field=$wp" . self::_quote_string($value) . "$ws)"; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (count($attrs) > 1) |
| | | $filter .= '(|'; |
| | | foreach ($attrs as $f) |
| | | $filter .= "($f=$wp" . $this->_quote_string($val) . "$ws)"; |
| | | $filter .= "($f=$wp" . self::_quote_string($val) . "$ws)"; |
| | | if (count($attrs) > 1) |
| | | $filter .= ')'; |
| | | } |
| | |
| | | } |
| | | |
| | | // Build the new entries DN. |
| | | $dn = $this->prop['LDAP_rdn'].'='.$this->_quote_string($newentry[$this->prop['LDAP_rdn']], true).','.$this->base_dn; |
| | | $dn = $this->prop['LDAP_rdn'].'='.self::_quote_string($newentry[$this->prop['LDAP_rdn']], true).','.$this->base_dn; |
| | | |
| | | // Remove attributes that need to be added separately (child objects) |
| | | $xfields = array(); |
| | |
| | | } |
| | | |
| | | foreach ($xfields as $xidx => $xf) { |
| | | $xdn = $xidx.'='.$this->_quote_string($xf).','.$dn; |
| | | $xdn = $xidx.'='.self::_quote_string($xf).','.$dn; |
| | | $xf = array( |
| | | $xidx => $xf, |
| | | 'objectClass' => (array) $this->prop['sub_fields'][$xidx], |
| | |
| | | // Handle RDN change |
| | | if ($replacedata[$this->prop['LDAP_rdn']]) { |
| | | $newdn = $this->prop['LDAP_rdn'].'=' |
| | | .$this->_quote_string($replacedata[$this->prop['LDAP_rdn']], true) |
| | | .self::_quote_string($replacedata[$this->prop['LDAP_rdn']], true) |
| | | .','.$this->base_dn; |
| | | if ($dn != $newdn) { |
| | | $newrdn = $this->prop['LDAP_rdn'].'=' |
| | | .$this->_quote_string($replacedata[$this->prop['LDAP_rdn']], true); |
| | | .self::_quote_string($replacedata[$this->prop['LDAP_rdn']], true); |
| | | unset($replacedata[$this->prop['LDAP_rdn']]); |
| | | } |
| | | } |
| | |
| | | // remove sub-entries |
| | | if (!empty($subdeldata)) { |
| | | foreach ($subdeldata as $fld => $val) { |
| | | $subdn = $fld.'='.$this->_quote_string($val).','.$dn; |
| | | $subdn = $fld.'='.self::_quote_string($val).','.$dn; |
| | | if (!$this->ldap->delete($subdn)) { |
| | | return false; |
| | | } |
| | |
| | | // add sub-entries |
| | | if (!empty($subnewdata)) { |
| | | foreach ($subnewdata as $fld => $val) { |
| | | $subdn = $fld.'='.$this->_quote_string($val).','.$dn; |
| | | $subdn = $fld.'='.self::_quote_string($val).','.$dn; |
| | | $xf = array( |
| | | $fld => $val, |
| | | 'objectClass' => (array) $this->prop['sub_fields'][$fld], |
| | |
| | | */ |
| | | function create_group($group_name) |
| | | { |
| | | $base_dn = $this->groups_base_dn; |
| | | $new_dn = "cn=$group_name,$base_dn"; |
| | | $new_gid = self::dn_encode($group_name); |
| | | $new_dn = 'cn=' . self::_quote_string($group_name, true) . ',' . $this->groups_base_dn; |
| | | $new_gid = self::dn_encode($new_dn); |
| | | $member_attr = $this->get_group_member_attr(); |
| | | $name_attr = $this->prop['groups']['name_attr'] ? $this->prop['groups']['name_attr'] : 'cn'; |
| | | |
| | |
| | | if (($group_cache = $this->cache->get('groups')) === null) |
| | | $group_cache = $this->_fetch_groups(); |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $group_name = $group_cache[$group_id]['name']; |
| | | $del_dn = "cn=$group_name,$base_dn"; |
| | | $del_dn = $group_cache[$group_id]['dn']; |
| | | |
| | | if (!$this->ldap->delete($del_dn)) { |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return false; |
| | | } |
| | | |
| | | $this->cache->remove('groups'); |
| | | unset($group_cache[$group_id]); |
| | | $this->cache->set('groups', $group_cache); |
| | | |
| | | return true; |
| | | } |
| | |
| | | if (($group_cache = $this->cache->get('groups')) === null) |
| | | $group_cache = $this->_fetch_groups(); |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $group_name = $group_cache[$group_id]['name']; |
| | | $old_dn = "cn=$group_name,$base_dn"; |
| | | $new_rdn = "cn=$new_name"; |
| | | $new_gid = self::dn_encode($new_name); |
| | | $old_dn = $group_cache[$group_id]['dn']; |
| | | $new_rdn = "cn=" . self::_quote_string($new_name, true); |
| | | $new_gid = self::dn_encode($new_rdn . ',' . $this->groups_base_dn); |
| | | |
| | | if (!$this->ldap->rename($old_dn, $new_rdn, null, true)) { |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | |
| | | if (!is_array($contact_ids)) |
| | | $contact_ids = explode(',', $contact_ids); |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $group_name = $group_cache[$group_id]['name']; |
| | | $member_attr = $group_cache[$group_id]['member_attr']; |
| | | $group_dn = "cn=$group_name,$base_dn"; |
| | | $group_dn = $group_cache[$group_id]['dn']; |
| | | |
| | | $new_attrs = array(); |
| | | foreach ($contact_ids as $id) |
| | |
| | | |
| | | $this->cache->remove('groups'); |
| | | |
| | | return count($new_attrs['member']); |
| | | return count($new_attrs[$member_attr]); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (($group_cache = $this->cache->get('groups')) === null) |
| | | $group_cache = $this->_fetch_groups(); |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $group_name = $group_cache[$group_id]['name']; |
| | | $member_attr = $group_cache[$group_id]['member_attr']; |
| | | $group_dn = "cn=$group_name,$base_dn"; |
| | | $group_dn = $group_cache[$group_id]['dn']; |
| | | |
| | | $del_attrs = array(); |
| | | foreach (explode(",", $contact_ids) as $id) |
| | | foreach ($contact_ids as $id) |
| | | $del_attrs[$member_attr][] = self::dn_decode($id); |
| | | |
| | | if (!$this->ldap->mod_del($group_dn, $del_attrs)) { |
| | |
| | | |
| | | $this->cache->remove('groups'); |
| | | |
| | | return count($del_attrs['member']); |
| | | return count($del_attrs[$member_attr]); |
| | | } |
| | | |
| | | /** |