Description: Don't count LDAP objects if search/list result is false (bool).
Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

--- a/include/functions.inc
+++ b/include/functions.inc
@@ -3803,7 +3803,12 @@
             array('dn'));
 
     // If we haven't created the character-detection object, then create it now.
-    $cnt = ldap_count_entries($ldapCID, $res);
+    if ($res) {
+        $cnt = ldap_count_entries($ldapCID, $res);
+    }
+    else {
+        $cnt = 0;
+    }
     if(!$cnt){
         $obj = array();
         $obj['objectClass'] = array('top','organization');
@@ -3819,7 +3824,12 @@
     $res = ldap_list($ldapCID, $config->current['BASE'],
             "(&(o=".$filterName.")(objectClass=organization))",
             array('dn','o'));
-    $cnt = ldap_count_entries($ldapCID, $res);
+    if ($res) {
+        $cnt = ldap_count_entries($ldapCID, $res);
+    }
+    else {
+        $cnt = 0;
+    }
     if($cnt != 1 || !$res){
         trigger_error("GOsa couldn't detect the special character handling used by your ldap!");
         return(NULL);
