2 commits - lib/api lib/Auth.php lib/ext

Aleksander Machniak machniak at kolabsys.com
Thu Oct 4 09:18:33 CEST 2012


 lib/Auth.php                             |    4 +--
 lib/api/kolab_api_service_form_value.php |    8 ++++--
 lib/ext/Net/LDAP3.php                    |   37 +++++++++++++++++++++++--------
 3 files changed, 35 insertions(+), 14 deletions(-)

New commits:
commit 649a5ecceeaaf2510d1c92a581dc5086b8ba3939
Author: Aleksander Machniak <alec at alec.pl>
Date:   Thu Oct 4 09:18:10 2012 +0200

    Renamed Auth methods - removed ldap_ prefix

diff --git a/lib/Auth.php b/lib/Auth.php
index db61490..ec705a9 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -416,12 +416,12 @@ class Auth {
         return $this->auth_instance()->user_info($userdata);
     }
 
-    public function ldap_schema_attributes($object_classes)
+    public function schema_attributes($object_classes)
     {
         return $this->auth_instance()->attributes_allowed($object_classes);
     }
 
-    public function ldap_schema_classes()
+    public function schema_classes()
     {
         return $this->auth_instance()->classes_allowed();
     }
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index a4eac28..fd57060 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -770,7 +770,7 @@ class kolab_api_service_form_value extends kolab_api_service
     private function select_options_objectclass($postdata, $attribs = array())
     {
         $auth = Auth::get_instance();
-        $list = $auth->ldap_schema_classes();
+        $list = $auth->schema_classes();
 
         if (is_array($list)) {
             sort($list);
@@ -782,7 +782,7 @@ class kolab_api_service_form_value extends kolab_api_service
     private function select_options_attribute($postdata, $attribs = array())
     {
         $auth = Auth::get_instance();
-        $list = $auth->ldap_schema_attributes($postdata['classes']);
+        $list = $auth->schema_attributes($postdata['classes']);
 
         if (is_array($list['may'])) {
             sort($list['may']);


commit 48573936705641cf1ca03354838fef344d186162
Author: Aleksander Machniak <alec at alec.pl>
Date:   Thu Oct 4 09:17:20 2012 +0200

    Fix Net_LDAP2 connection error handling (Bug #1053)

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index d854d3e..a4eac28 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -772,7 +772,9 @@ class kolab_api_service_form_value extends kolab_api_service
         $auth = Auth::get_instance();
         $list = $auth->ldap_schema_classes();
 
-        sort($list);
+        if (is_array($list)) {
+            sort($list);
+        }
 
         return array('list' => $list);
     }
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index c722fce..75c01a5 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -222,9 +222,13 @@ class Net_LDAP3
 
     public function attribute_details($attributes = array())
     {
-        $_schema = $this->init_schema();
+        $schema = $this->init_schema();
 
-        $attribs = $_schema->getAll('attributes');
+        if (!$schema) {
+            return array();
+        }
+
+        $attribs = $schema->getAll('attributes');
 
         $attributes_details = array();
 
@@ -272,14 +276,18 @@ class Net_LDAP3
         $this->_debug("Listing allowed_attributes for objectclasses", $objectclasses);
 
         if (!is_array($objectclasses)) {
-            return FALSE;
+            return false;
         }
 
         if (empty($objectclasses)) {
-            return FALSE;
+            return false;
+        }
+
+        $schema = $this->init_schema();
+        if (!$schema) {
+            return false;
         }
 
-        $schema       = $this->init_schema();
         $may          = array();
         $must         = array();
         $superclasses = array();
@@ -312,7 +320,11 @@ class Net_LDAP3
 
     public function classes_allowed()
     {
-        $schema  = $this->init_schema();
+        $schema = $this->init_schema();
+        if (!$schema) {
+            return false;
+        }
+
         $list    = $schema->getAll('objectclasses');
         $classes = array();
 
@@ -1655,17 +1667,24 @@ class Net_LDAP3
                 'max_age' => 86400,
             );
 
-            $_ldap_schema_cache = new Net_LDAP2_SimpleFileSchemaCache($_ldap_schema_cache_cfg);
+            $_ldap = Net_LDAP2::connect($_ldap_cfg);
 
-            if ($_ldap = Net_LDAP2::connect($_ldap_cfg)) {
+            if (!is_a($_ldap, 'Net_LDAP2_Error')) {
                 $this->_debug("S: OK");
                 break;
             }
 
             $this->_debug("S: NOT OK");
+            new PEAR_Error($_ldap->getMessage());
         }
 
-        $result = $_ldap->registerSchemaCache($_ldap_schema_cache);
+        if (is_a($_ldap, 'Net_LDAP2_Error')) {
+            return null;
+        }
+
+        $_ldap_schema_cache = new Net_LDAP2_SimpleFileSchemaCache($_ldap_schema_cache_cfg);
+
+        $_ldap->registerSchemaCache($_ldap_schema_cache);
 
         // TODO: We should learn what LDAP tech. we're running against.
         // Perhaps with a scope base objectclass recognize rootdse entry





More information about the commits mailing list