diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-08-27 06:29:24 (GMT) |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-08-27 06:29:24 (GMT) |
commit | 3b76ee09bfcdd436fa3c1211abaf43bcb029d2de (patch) | |
tree | 3741695eec606b7f66037511a11cdda4bc993fbb | |
parent | 6b659410265a34e1c5b321e03e77a2745231536d (diff) | |
download | kolab-wap-3b76ee09bfcdd436fa3c1211abaf43bcb029d2de.tar.gz |
Update Net_LDAP3 lib
-rw-r--r-- | lib/ext/Net/LDAP3.php | 29 | ||||
-rw-r--r-- | lib/ext/Net/LDAP3/Result.php | 19 |
2 files changed, 30 insertions, 18 deletions
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php index 34baa2c..86c6310 100644 --- a/lib/ext/Net/LDAP3.php +++ b/lib/ext/Net/LDAP3.php @@ -992,7 +992,9 @@ class Net_LDAP3 $result = $ldap->search($root_dn, '(objectclass=nsds5replicationagreement)', 'sub', array('nsds5replicahost')); if (!$result) { - $this->_debug("No replicas configured"); + $this->_debug("No replicas configured on $replica_host"); + $ldap->close(); + continue; } foreach ($result->entries(true) as $dn => $attrs) { @@ -1852,12 +1854,15 @@ class Net_LDAP3 // Not passing any sort attributes means you don't care if (!empty($sort_attrs)) { $sort_attrs = (array) $sort_attrs; - if (count(array_intersect($sort_attrs, $vlv_index[$base_dn]['sort'])) == count($sort_attrs)) { - return $sort_attrs; - } - else { - return false; + foreach ($vlv_index[$base_dn]['sort'] as $sss_config) { + if (count(array_intersect($sort_attrs, $sss_config)) == count($sort_attrs)) { + return $sort_attrs; + } } + + $this->_error("The requested sorting does not match any server-side sorting configuration"); + + return false; } else { return $vlv_index[$base_dn]['sort'][0]; @@ -2180,25 +2185,19 @@ class Net_LDAP3 } } - // Use ldap_modify() not ldap_mod_replace(), this is the only way to update entry - // in case of objectClass change (Bug #1921) if (is_array($attributes['replace']) && !empty($attributes['replace'])) { - $attrs = array_merge($attributes['replace'], $attributes['add']); + $this->_debug("LDAP: C: Mod-Replace $subject_dn: " . json_encode($attributes['replace'])); - $this->_debug("LDAP: C: Modify $subject_dn: " . json_encode($attrs)); - - $result = ldap_modify($this->conn, $subject_dn, $attrs); + $result = ldap_mod_replace($this->conn, $subject_dn, $attributes['replace']); if ($result) { $this->_debug("LDAP: S: OK"); } else { $this->_debug("LDAP: S: " . ldap_error($this->conn)); - $this->_warning("LDAP: Failed to replace attributes on $subject_dn: " . json_encode($attrs)); + $this->_warning("LDAP: Failed to replace attributes on $subject_dn: " . json_encode($attributes['replace'])); return false; } - - unset($attributes['add'], $attributes['replace']); } if (is_array($attributes['del']) && !empty($attributes['del'])) { diff --git a/lib/ext/Net/LDAP3/Result.php b/lib/ext/Net/LDAP3/Result.php index 728b304..0759df0 100644 --- a/lib/ext/Net/LDAP3/Result.php +++ b/lib/ext/Net/LDAP3/Result.php @@ -71,7 +71,7 @@ class Net_LDAP3_Result implements Iterator } /** - * + * Wrapper for ldap_sort() */ public function sort($attr) { @@ -79,18 +79,23 @@ class Net_LDAP3_Result implements Iterator } /** - * + * Get entries count */ public function count() { - if (!isset($this->count)) + if (!isset($this->count)) { $this->count = ldap_count_entries($this->conn, $this->result); + } return $this->count; } /** + * Wrapper for ldap_get_entries() * + * @param bool $normalize Optionally normalize the entries to a list of hash arrays + * + * @return array List of LDAP entries */ public function entries($normalize = false) { @@ -103,6 +108,14 @@ class Net_LDAP3_Result implements Iterator return $entries; } + /** + * Wrapper for ldap_get_dn() using the current entry pointer + */ + public function get_dn() + { + return $this->current ? ldap_get_dn($this->conn, $this->current) : null; + } + /*** Implement PHP 5 Iterator interface to make foreach work ***/ |