| | |
| | | $replaces = array('%dn' => '', '%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u); |
| | | |
| | | if ($this->prop['search_base_dn'] && $this->prop['search_filter']) { |
| | | if (!empty($this->prop['search_bind_dn']) && !empty($this->prop['search_bind_pw'])) { |
| | | $this->bind($this->prop['search_bind_dn'], $this->prop['search_bind_pw']); |
| | | } |
| | | |
| | | // Search for the dn to use to authenticate |
| | | $this->prop['search_base_dn'] = strtr($this->prop['search_base_dn'], $replaces); |
| | | $this->prop['search_filter'] = strtr($this->prop['search_filter'], $replaces); |
| | |
| | | |
| | | $attrib = $count ? array('dn') : array_values($this->fieldmap); |
| | | if ($result = @$func($this->conn, $m[1], $filter, |
| | | $attrib, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit'])) |
| | | { |
| | | $attrib, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit']) |
| | | ) { |
| | | $this->_debug("S: ".ldap_count_entries($this->conn, $result)." record(s) for ".$m[1]); |
| | | if ($err = ldap_errno($this->conn)) |
| | | $this->_debug("S: Error: " .ldap_err2str($err)); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | $this->_debug("S: ".ldap_error($this->conn)); |
| | | return $group_members; |
| | | } |
| | |
| | | $dn = self::dn_encode($dn); |
| | | |
| | | // add new contact to the selected group |
| | | if ($this->groups) |
| | | if ($this->group_id) |
| | | $this->add_to_group($this->group_id, $dn); |
| | | |
| | | return $dn; |
| | |
| | | // only fetch dn for count (should keep the payload low) |
| | | $attrs = $count ? array('dn') : array_values($this->fieldmap); |
| | | if ($this->ldap_result = @$function($this->conn, $this->base_dn, $filter, |
| | | $attrs, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit'])) |
| | | { |
| | | $this->_debug("S: ".ldap_count_entries($this->conn, $this->ldap_result)." record(s)"); |
| | | if ($err = ldap_errno($this->conn)) |
| | | $this->_debug("S: Error: " .ldap_err2str($err)); |
| | | return $count ? ldap_count_entries($this->conn, $this->ldap_result) : true; |
| | | $attrs, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit']) |
| | | ) { |
| | | $entries_count = ldap_count_entries($this->conn, $this->ldap_result); |
| | | $this->_debug("S: $count_entries record(s)"); |
| | | |
| | | return $count ? $count_entries : true; |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | $this->_debug("S: ".ldap_error($this->conn)); |
| | | } |
| | | } |
| | |
| | | if (($group_cache = $this->cache->get('groups')) === null) |
| | | $group_cache = $this->_fetch_groups(); |
| | | |
| | | 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"; |
| | | |
| | | $new_attrs = array(); |
| | | foreach (explode(",", $contact_ids) as $id) |
| | | foreach ($contact_ids as $id) |
| | | $new_attrs[$member_attr][] = self::dn_decode($id); |
| | | |
| | | $this->_debug("C: Add [dn: $group_dn]: ".print_r($new_attrs, true)); |