summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-03-05 10:07:07 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-03-05 10:07:07 (GMT)
commitd5c7eeb50de5e0952a0e303a1cd1e046dbdb0eb0 (patch)
tree69c9ebc6203247d02f1b85c5212e8032b60760d2
parent74319e95a36347f474e49bbbff04e95a561c106e (diff)
downloadkolab-wap-d5c7eeb50de5e0952a0e303a1cd1e046dbdb0eb0.tar.gz
Fix regression related to incorrect find_domain() result handling (#4786)
-rw-r--r--lib/Auth/LDAP.php8
-rw-r--r--lib/ext/Net/LDAP3.php14
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 1588500..ce0762e 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -430,7 +430,11 @@ class LDAP extends Net_LDAP3 {
$domain_dn = $this->entry_dn($domain, array(), $domain_base_dn);
if (!$domain_dn) {
- $result = $this->find_domain($domain, $attributes);
+ if ($result = $this->find_domain($domain, $attributes)) {
+ $result_dn = $result['dn'];
+ unset($result['dn']);
+ $result = array($result_dn => $result);
+ }
}
else {
$result = $this->_read($domain_dn, $attributes);
@@ -1042,7 +1046,7 @@ class LDAP extends Net_LDAP3 {
* @param string $domain Domain name
* @param array $attributes Result attributes
*
- * @return array|bool Domain attributes or False on error
+ * @return array|bool Domain attributes (+ 'dn' attribute) or False on error
*/
public function find_domain($domain, $attributes = array('*'))
{
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 00a4483..30f40df 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -3029,7 +3029,7 @@ class Net_LDAP3
* @param string $domain Domain name
* @param array $attributes Result attributes
*
- * @return array|bool Domain attributes or False if not found
+ * @return array|bool Domain attributes (plus 'dn' attribute) or False if not found
*/
public function find_domain($domain, $attributes = array('*'))
{
@@ -3051,7 +3051,10 @@ class Net_LDAP3
if ($domain_dn) {
$result = $this->get_entry_attributes($domain_dn, $attributes);
- if (empty($result)) {
+ if (!empty($result)) {
+ $result['dn'] = $domain_dn;
+ }
+ else {
$result = false;
}
}
@@ -3067,9 +3070,10 @@ class Net_LDAP3
$domain_filter = "(&" . $domain_filter . "(" . $name_attribute . "=" . self::quote_string($domain) . "))";
if ($result = $this->search($domain_base_dn, $domain_filter, 'sub', $attributes)) {
- $result = $result->entries(true);
- $domain_dn = key($result);
- $result = $result[$domain_dn];
+ $result = $result->entries(true);
+ $domain_dn = key($result);
+ $result = $result[$domain_dn];
+ $result['dn'] = $domain_dn;
// cache domain DN
$this->set_cache_data($ckey, $domain_dn);