From 8eae72a53cf4e359643a75c03d4317bd9afbac77 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 05 Mar 2012 09:20:07 -0500
Subject: [PATCH] - Add check_connection() to storage abstract class

---
 program/include/rcube_ldap.php |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index c3893d8..d22dc6a 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -63,7 +63,7 @@
     /**
     * Object constructor
     *
-    * @param array 	LDAP connection properties
+    * @param array 	    LDAP connection properties
     * @param boolean 	Enables debug mode
     * @param string 	Current user mail domain name
     * @param integer User-ID
@@ -95,7 +95,7 @@
             foreach ($p['fieldmap'] as $rf => $lf)
                 $this->fieldmap[$rf] = $this->_attr_name(strtolower($lf));
         }
-        else {
+        else if (!empty($p)) {
             // read deprecated *_field properties to remain backwards compatible
             foreach ($p as $prop => $value)
                 if (preg_match('/^(.+)_field$/', $prop, $matches))
@@ -554,7 +554,7 @@
             $entries = @ldap_get_entries($this->conn, $result);
         }
 
-        for ($i=0; $i < $entries["count"]; $i++)
+        for ($i=0; $i < $entries['count']; $i++)
         {
             $entry = $entries[$i];
 
@@ -564,6 +564,7 @@
             foreach ((array)$entry['objectclass'] as $objectclass)
             {
                 switch (strtolower($objectclass)) {
+                    case "group":
                     case "groupofnames":
                     case "kolabgroupofnames":
                         $group_members = array_merge($group_members, $this->_list_group_members($dn, $entry, 'member', $count));
@@ -577,7 +578,7 @@
                         break;
                 }
             }
-            
+
             if ($this->prop['sizelimit'] && count($group_members) > $this->prop['sizelimit'])
               break;
         }
@@ -610,6 +611,9 @@
 
         for ($i=0; $i < $entry[$attr]['count']; $i++)
         {
+            if (empty($entry[$attr][$i]))
+                continue;
+
             $result = @ldap_read($this->conn, $entry[$attr][$i], '(objectclass=*)',
                 $attrib, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit']);
 
@@ -1538,6 +1542,7 @@
             // check objectClass attributes of group and act accordingly
             for ($j=0; $j < $ldap_data[$i]['objectclass']['count']; $j++) {
                 switch (strtolower($ldap_data[$i]['objectclass'][$j])) {
+                    case 'group':
                     case 'groupofnames':
                     case 'kolabgroupofnames':
                         $groups[$group_id]['member_attr'] = 'member';

--
Gitblit v1.9.1