5 commits - lib/api lib/Auth lib/Auth.php

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Mon Aug 6 15:09:59 CEST 2012


 lib/Auth.php                             |    8 +++++-
 lib/Auth/LDAP.php                        |   37 +++++++++++++++++++++++++++++--
 lib/api/kolab_api_service_domain.php     |    5 ++++
 lib/api/kolab_api_service_form_value.php |   17 ++++++++++++++
 4 files changed, 64 insertions(+), 3 deletions(-)

New commits:
commit 0e2c7ea47b6fd7793883ba17445695db75739a69
Merge: a5ef1ae d72a655
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Aug 6 15:09:54 2012 +0200

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



commit a5ef1ae5ba0c1ac48ccebfa0341502104b7650e5
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Aug 6 15:09:04 2012 +0200

    If the result is empty, set domain as the id

diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index 3d1b9dd..750062c 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -80,6 +80,7 @@ class kolab_api_service_domain extends kolab_api_service
 
     public function domain_add($getdata, $postdata)
     {
+        //console("api::domain_add(\$getdata, \$postdata)", $getdata, $postdata);
         $conf = Conf::get_instance();
         $dna = $conf->get('domain_name_attribute');
 
@@ -170,6 +171,10 @@ class kolab_api_service_domain extends kolab_api_service
         // normalize result
         $result = $this->parse_result_attributes('domain', $result);
 
+        if (empty($result['id'])) {
+            $result['id'] = $getdata['domain'];
+        }
+
         //console("API/domain.info() \$result:", $result);
 
         if ($result) {


commit 826fc0af62f28abc691b7387bb1561330f1fb297
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Aug 6 15:08:42 2012 +0200

    Add validation of associateddomain

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 6278c36..049c290 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -834,6 +834,23 @@ class kolab_api_service_form_value extends kolab_api_service
 
     }
 
+    private function validate_associateddomain($value)
+    {
+        return $value;
+
+        $auth = Auth::get_instance();
+        $conf = Conf::get_instance();
+
+        if (!is_array($value)) {
+            $value = (array)($value);
+        }
+
+        //console("form_value.validate_associateddomain(\$value)", $value);
+
+        return $value;
+
+    }
+
     private function validate_mail($value)
     {
         $auth = Auth::get_instance();


commit 25098fd4e2cd4a1f867cdc7e9606e81cb40593c7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Aug 6 15:08:18 2012 +0200

    Add function role_add

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 0cd9f1c..28233c1 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -312,18 +312,28 @@ class LDAP
     {
         // Domain identifier
         $unique_attr = $this->unique_attribute();
-        $attributes[$unique_attr] = $domain;
 
         // Now that values have been re-generated where necessary, compare
         // the new domain attributes to the original domain attributes.
         $_domain = $this->domain_find_by_attribute(array($unique_attr => $attributes[$unique_attr]));
 
+        if (empty($_domain)) {
+            $_domain = $this->entry_dn($domain);
+
+            if (empty($_domain)) {
+                return false;
+            }
+
+            $_domain_dn = $domain;
+        } else {
+            $_domain_dn = key($_domain);
+        }
+
         if (!$_domain) {
             //console("Could not find domain");
             return false;
         }
 
-        $_domain_dn = key($_domain);
         $_domain = $this->domain_info($_domain_dn, array_keys($attributes));
 
         // We should start throwing stuff over the fence here.
@@ -820,6 +830,29 @@ class LDAP
         return $this->_list_resource_members($resource_dn, null, $recurse);
     }
 
+    public function role_add($attrs)
+    {
+        if ($typeid == null) {
+            $type_str = 'role';
+        }
+        else {
+            $db   = SQL::get_instance();
+            $_key = $db->fetch_assoc($db->query("SELECT `key` FROM role_types WHERE id = ?", $typeid));
+            $type_str = $_key['key'];
+        }
+
+        // Check if the user_type has a specific base DN specified.
+        $base_dn = $this->conf->get($this->domain, $type_str . "base_dn");
+        if (empty($base_dn))
+            $base_dn = $this->conf->get('ldap', "base_dn");
+
+        // TODO: The rdn is configurable as well.
+        // Use [$type_str . "_"]user_rdn_attr
+        $dn = "cn=" . $attrs['cn'] . "," . $base_dn;
+
+        return $this->_add($dn, $attrs);
+    }
+
     public function role_find_by_attribute($attribute)
     {
         //console("Finding role by attribute", $attribute);


commit fab4e2d435ef2b4031401089b808ed4317ac5da0
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Aug 6 15:07:42 2012 +0200

    Make sure to connect before listing roles
    Add function role_add()

diff --git a/lib/Auth.php b/lib/Auth.php
index 90159d7..d6f647e 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -349,11 +349,12 @@ class Auth {
 
     public function list_roles($domain = NULL, $attributes = array(), $search = array(), $params = array())
     {
-        $this->connect($domain);
         if ($domain === NULL) {
             $domain = $this->conf->get('primary_domain');
         }
 
+        $this->connect($domain);
+
         $roles = $this->_auth[$domain]->list_roles($attributes, $search, $params);
 
         return $roles;
@@ -413,6 +414,11 @@ class Auth {
         return $this->_auth[$_SESSION['user']->get_domain()]->resource_members_list($resourcedata, $recurse);
     }
 
+    public function role_add($role)
+    {
+        return $this->_auth[$_SESSION['user']->get_domain()]->role_add($role);
+    }
+
     public function role_find_by_attribute($attribute)
     {
         return $this->_auth[$_SESSION['user']->get_domain()]->role_find_by_attribute($attribute);





More information about the commits mailing list