3 commits - lib/api lib/Auth

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Tue Aug 7 11:45:51 CEST 2012


 lib/Auth/LDAP.php                    |   20 +++++++++++++-------
 lib/api/kolab_api_service_domain.php |    2 +-
 2 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit c4013c71df0f41e7c0ba20cebef48328e60152e2
Merge: 7c311aa 0e7b4b7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Aug 7 11:45:43 2012 +0200

    Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap



commit 7c311aa1a1770f2d7ed441cb4f60a23175c554c2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Aug 7 11:45:29 2012 +0200

    Invert parent and alias domain name space(s)

diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index 7f93de6..11c4d22 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -96,7 +96,7 @@ class kolab_api_service_domain extends kolab_api_service
 
         if (is_array($postdata[$dna])) {
             $parent_domain = array_shift($postdata[$dna]);
-            return $auth->domain_add($parent_domain, $postdata[$dna]);
+            return $auth->domain_add($postdata[$dna], $parent_domain);
         } else {
             return $auth->domain_add($postdata[$dna]);
         }


commit 41cd79514f421cbf3d40e3f47c01c73a37f12db0
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Aug 7 11:44:16 2012 +0200

    Before adding a domain as an alias, verify if the domain exists. If not, add the domain first.
    Correctly merge and apply any additional domain name spaces that may be specified with adding a domain.
    Unique the list of domain name spaces added.

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 8fb5f42..e4b6e9d 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -301,6 +301,10 @@ class LDAP
     {
         // Apply some routines for access control to this function here.
         if (!empty($parent_domain)) {
+            if (!$this->domain_info($parent_domain)) {
+                $this->_domain_add_new($parent_domain, $prepopulate);
+            }
+
             return $this->_domain_add_alias($domain, $parent_domain);
         }
         else {
@@ -1824,18 +1828,18 @@ class LDAP
 
         $domain_name_attribute = $conf->get('ldap', 'domain_name_attribute');
 
+        // Get the parent
         $domain_filter = '(&(' . $domain_name_attribute . '=' . $parent . ')' . $domain_filter . ')';
 
         $domain_entry = self::normalize_result($this->_search($domain_base_dn, $domain_filter));
-
-        // TODO: Catch not having found any such parent domain
-
         $domain_dn = key($domain_entry);
 
-        //    private function modify_entry($subject_dn, $old_attrs, $new_attrs)
-
         $_old_attr = array($domain_name_attribute => $domain_entry[$domain_dn][$domain_name_attribute]);
-        $_new_attr = array($domain_name_attribute => array($domain_entry[$domain_dn][$domain_name_attribute], $domain));
+        if (is_array($domain)) {
+            $_new_attr = array($domain_name_attribute => array_unique(array_merge((array)($domain_entry[$domain_dn][$domain_name_attribute]), $domain)));
+        } else {
+            $_new_attr = array($domain_name_attribute => array($domain_entry[$domain_dn][$domain_name_attribute], $domain));
+        }
 
         return $this->modify_entry($domain_dn, $_old_attr, $_new_attr);
     }
@@ -1862,7 +1866,9 @@ class LDAP
                         'top',
                         'domainrelatedobject'
                     ),
-                $domain_name_attribute => array_merge((array)($domain_name), $domain),
+                $domain_name_attribute => array_unique(
+                        array_merge((array)($domain_name), $domain)
+                    ),
             );
 
         $this->_add($dn, $attrs);





More information about the commits mailing list