| | |
| | | $filter = $this->filter ? $this->filter : '(objectclass=*)'; |
| | | $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); |
| | | |
| | | $this->_debug("C: Search [".$filter."]"); |
| | | $this->_debug("C: Search [$filter]"); |
| | | |
| | | // when using VLV, we get the total count by... |
| | | if (!$count && $function != 'ldap_read' && $this->prop['vlv']) { |
| | |
| | | $base_dn = $this->groups_base_dn; |
| | | $filter = $this->prop['groups']['filter']; |
| | | |
| | | $this->_debug("C: Search [$filter][dn: $base_dn]"); |
| | | |
| | | $res = ldap_search($this->conn, $base_dn, $filter, array('cn','member')); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return array(); |
| | | } |
| | | |
| | | $ldap_data = ldap_get_entries($this->conn, $res); |
| | | $this->_debug("S: ".ldap_count_entries($this->conn, $res)." record(s)"); |
| | | |
| | | $groups = array(); |
| | | $group_sortnames = array(); |
| | |
| | | 'member' => '', |
| | | ); |
| | | |
| | | $this->_debug("C: Add [dn: $new_dn]: ".print_r($new_entry, true)); |
| | | |
| | | $res = ldap_add($this->conn, $new_dn, $new_entry); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return false; |
| | | } |
| | | |
| | | $this->_debug("S: OK"); |
| | | |
| | | return array('id' => $new_gid, 'name' => $group_name); |
| | | } |
| | | |
| | |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $group_name = $this->group_cache[$group_id]['name']; |
| | | |
| | | $del_dn = "cn=$group_name,$base_dn"; |
| | | |
| | | $this->_debug("C: Delete [dn: $del_dn]"); |
| | | |
| | | $res = ldap_delete($this->conn, $del_dn); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return false; |
| | | } |
| | | |
| | | $this->_debug("S: OK"); |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | $new_rdn = "cn=$new_name"; |
| | | $new_gid = base64_encode($new_name); |
| | | |
| | | $this->_debug("C: Rename [dn: $old_dn] [dn: $new_rdn]"); |
| | | |
| | | $res = ldap_rename($this->conn, $old_dn, $new_rdn, NULL, TRUE); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return false; |
| | | } |
| | | |
| | | $this->_debug("S: OK"); |
| | | |
| | | return $new_name; |
| | | } |
| | | |
| | |
| | | foreach (explode(",", $contact_ids) as $id) |
| | | $new_attrs['member'][] = base64_decode($id); |
| | | |
| | | $this->_debug("C: Add [dn: $group_dn]: ".print_r($new_attrs, true)); |
| | | |
| | | $res = ldap_mod_add($this->conn, $group_dn, $new_attrs); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return 0; |
| | | } |
| | | |
| | | $this->_debug("S: OK"); |
| | | |
| | | return count($new_attrs['member']); |
| | | } |
| | | |
| | |
| | | foreach (explode(",", $contact_ids) as $id) |
| | | $del_attrs['member'][] = base64_decode($id); |
| | | |
| | | $this->_debug("C: Delete [dn: $group_dn]: ".print_r($del_attrs, true)); |
| | | |
| | | $res = ldap_mod_del($this->conn, $group_dn, $del_attrs); |
| | | if ($res === false) |
| | | { |
| | |
| | | $this->set_error(self::ERROR_SAVING, 'errorsaving'); |
| | | return 0; |
| | | } |
| | | |
| | | $this->_debug("S: OK"); |
| | | |
| | | return count($del_attrs['member']); |
| | | } |
| | | |
| | |
| | | $contact_dn = base64_decode($contact_id); |
| | | $filter = "(member=$contact_dn)"; |
| | | |
| | | $this->_debug("C: Search [$filter][dn: $base_dn]"); |
| | | |
| | | $res = ldap_search($this->conn, $base_dn, $filter, array('cn')); |
| | | if ($res === false) |
| | | { |
| | |
| | | return array(); |
| | | } |
| | | $ldap_data = ldap_get_entries($this->conn, $res); |
| | | $this->_debug("S: ".ldap_count_entries($this->conn, $res)." record(s)"); |
| | | |
| | | $groups = array(); |
| | | for ($i=0; $i<$ldap_data["count"]; $i++) |