2 commits - lib/Auth
Aleksander Machniak
machniak at kolabsys.com
Wed Jul 10 15:25:05 CEST 2013
lib/Auth/LDAP.php | 63 ++++++++++++++++++++++++------------------------------
1 file changed, 28 insertions(+), 35 deletions(-)
New commits:
commit 407be9aca23da4a2310d4379f46254531ae2bf0c
Author: Aleksander Machniak <alec at alec.pl>
Date: Wed Jul 10 15:24:22 2013 +0200
Fix "PHP Warning: mb_strtoupper() expects parameter 1 to be string, array given"
in domains list sorting (for domains with aliases)
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5771af5..666f5bd 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1221,6 +1221,13 @@ class LDAP extends Net_LDAP3 {
$str2 = $b[$this->sort_result_key];
}
+ if (is_array($str1)) {
+ $str1 = array_shift($str1);
+ }
+ if (is_array($str2)) {
+ $str2 = array_shift($str2);
+ }
+
return strcmp(mb_strtoupper($str1), mb_strtoupper($str2));
}
commit 6df331c4291eb90e608a253c96007176142ef6a7
Author: Aleksander Machniak <alec at alec.pl>
Date: Wed Jul 10 15:21:57 2013 +0200
Fix inetdomainbasedn attribute handling in domain_add(), some code cleanup,
removed redundant LDAP search
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index e6d9d03..5771af5 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -158,6 +158,9 @@ class LDAP extends Net_LDAP3 {
$domain_base_dn = $this->conf->get('ldap', 'domain_base_dn');
$domain_name_attribute = $this->conf->get('ldap', 'domain_name_attribute');
+ $primary_domain = $this->conf->get('kolab', 'primary_domain');
+ $_primary_domain = str_replace('.', '_', $primary_domain);
+ $_domain = str_replace('.', '_', $domain);
if (empty($domain_name_attribute)) {
$domain_name_attribute = 'associateddomain';
@@ -171,10 +174,6 @@ class LDAP extends Net_LDAP3 {
array_unshift($attributes[$domain_name_attribute], $domain);
}
-// unset($attributes['aci']);
-// unset($attributes['inetdomainbasedn']);
-// unset($attributes['inetdomainstatus']);
-
$dn = $domain_name_attribute . '=' . $domain . ',' . $domain_base_dn;
$result = $this->add_entry($dn, $attributes);
@@ -183,9 +182,14 @@ class LDAP extends Net_LDAP3 {
return false;
}
- $inetdomainbasedn = $this->_standard_root_dn($domain);
- $_domain = str_replace('.', '_', $domain);
- $cn = str_replace(array(',', '='), array('\2C', '\3D'), $inetdomainbasedn);
+ if (!empty($attributes['inetdomainbasedn'])) {
+ $inetdomainbasedn = $attributes['inetdomainbasedn'];
+ }
+ else {
+ $inetdomainbasedn = $this->_standard_root_dn($domain);
+ }
+
+ $cn = str_replace(array(',', '='), array('\2C', '\3D'), $inetdomainbasedn);
$dn = "cn=" . $cn . ",cn=mapping tree,cn=config";
$attrs = array(
@@ -201,27 +205,9 @@ class LDAP extends Net_LDAP3 {
$this->add_entry($dn, $attrs);
- //
- // Use the information we find on the primary domain configuration for
- // the new domain configuration.
- //
- $domain_filter = $this->conf->get('ldap', 'domain_filter');
- $domain_filter = '(&(' . $domain_name_attribute . '=' . $this->conf->get('kolab', 'primary_domain') . ')' . $domain_filter . ')';
- $results = $this->_search($domain_base_dn, $domain_filter);
- $entries = $results->entries(true);
- $domain_entry = array_shift($entries);
-
- // The root_dn for the parent domain is needed to find the ldbm
- // database.
- if (in_array('inetdomainbasedn', $domain_entry)) {
- $_base_dn = $domain_entry['inetdomainbasedn'];
- } else {
- $_base_dn = $this->_standard_root_dn($this->conf->get('kolab', 'primary_domain'));
- }
-
- $result = $this->_read("cn=" . str_replace('.', '_', $this->conf->get('kolab', 'primary_domain') . ",cn=ldbm database,cn=plugins,cn=config"), array('nsslapd-directory'));
+ $result = $this->_read("cn=" . $_primary_domain . ",cn=ldbm database,cn=plugins,cn=config", array('nsslapd-directory'));
if (!$result) {
- $result = $this->_read("cn=" . $this->conf->get('kolab', 'primary_domain') . ",cn=ldbm database,cn=plugins,cn=config", array('nsslapd-directory'));
+ $result = $this->_read("cn=" . $primary_domain . ",cn=ldbm database,cn=plugins,cn=config", array('nsslapd-directory'));
}
if (!$result) {
@@ -230,14 +216,12 @@ class LDAP extends Net_LDAP3 {
$this->_log(LOG_DEBUG, "Primary domain ldbm database configuration entry: " . var_export($result, true));
- $result = $result[key($result)];
-
+ $result = $result[key($result)];
$orig_directory = $result['nsslapd-directory'];
-
- $directory = str_replace(str_replace('.', '_', $this->conf->get('kolab', 'primary_domain')), $_domain, $result['nsslapd-directory']);
+ $directory = str_replace($_primary_domain, $_domain, $result['nsslapd-directory']);
if ($directory == $orig_directory) {
- $directory = str_replace($this->conf->get('kolab', 'primary_domain'), $_domain, $result['nsslapd-directory']);
+ $directory = str_replace($primary_domain, $_domain, $result['nsslapd-directory']);
}
if ($directory == $orig_directory) {
@@ -264,16 +248,18 @@ class LDAP extends Net_LDAP3 {
$this->add_entry($dn, $attrs);
// Query the ACI for the primary domain
+ // Query the ACI for the primary domain
$domain_filter = $this->conf->get('ldap', 'domain_filter');
- $domain_filter = '(&(' . $domain_name_attribute . '=' . $this->conf->get('kolab', 'primary_domain') . ')' . $domain_filter . ')';
+ $domain_filter = '(&(' . $domain_name_attribute . '=' . $primary_domain . ')' . $domain_filter . ')';
$results = $this->_search($domain_base_dn, $domain_filter);
$entries = $results->entries(true);
$domain_entry = array_shift($entries);
if (in_array('inetdomainbasedn', $domain_entry)) {
$_base_dn = $domain_entry['inetdomainbasedn'];
- } else {
- $_base_dn = $this->_standard_root_dn($this->conf->get('kolab', 'primary_domain'));
+ }
+ else {
+ $_base_dn = $this->_standard_root_dn($primary_domain);
}
$result = $this->_read($_base_dn, array('aci'));
More information about the commits
mailing list