lib/api lib/Auth lib/Auth.php

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed Mar 21 16:19:19 CET 2012


 lib/Auth.php                       |    5 +++++
 lib/Auth/LDAP.php                  |   11 +++++++++++
 lib/api/kolab_api_service_user.php |   16 ++++++++++++++++
 3 files changed, 32 insertions(+)

New commits:
commit 9584c1921850f2a4ca8be09e1b2acc8550704af1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Mar 21 16:18:37 2012 +0100

    Add additional user information that may be specified as being a part of the user type, but is not returned as a result in your average LDAP query.

diff --git a/lib/Auth.php b/lib/Auth.php
index 9d7563e..b273e39 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -266,6 +266,11 @@ class Auth {
         return $this->_auth[$_SESSION['user']->get_domain()]->user_find_by_attribute($attribute);
     }
 
+    public function user_get_attribute($user, $attribute)
+    {
+        return $this->_auth[$_SESSION['user']->get_domain()]->user_get_attribute($user, $attribute);
+    }
+
     public function user_info($userdata)
     {
         return $this->normalize_result($this->_auth[$_SESSION['user']->get_domain()]->user_info($userdata));
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index b5bd9c9..e9eecf4 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -594,6 +594,17 @@ class LDAP
         }
     }
 
+    public function user_get_attribute($user_dn, $attribute)
+    {
+        $result = $this->normalize_result($this->search($user_dn, '(objectclass=*)', array($attribute)));
+
+        if (array_key_exists($attribute, $result[$user_dn])) {
+            return $result[$user_dn][$attribute];
+        } else {
+            return FALSE;
+        }
+    }
+
     public function user_info($user)
     {
         $is_dn = ldap_explode_dn($user, 1);
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index d8e79e7..0224b2b 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -121,6 +121,22 @@ class kolab_api_service_user extends kolab_api_service
         $objectclass = $result[$user]['objectclass'];
         $result[$user]['user_type_id'] = $this->user_type_id($objectclass);
 
+        // Search for attributes associated with the type_id that are not part
+        // of the results returned earlier. Example: nsrole / nsroledn / aci, etc.
+        $uta = $this->user_type_attributes($result[$user]['user_type_id']);
+
+        foreach ($uta as $field_type => $attributes) {
+            foreach ($attributes as $attribute => $data) {
+                if (!array_key_exists($attribute, $result[$user])) {
+                    $attribute_value = $auth->user_get_attribute($user, $attribute);
+                    if ($attribute_value) {
+                        console("Got:", $attribute_value);
+                        $result[$user][$attribute] = $attribute_value;
+                    }
+                }
+            }
+        }
+
         if ($result) {
             return $result;
         }





More information about the commits mailing list