Fix checking of return value from ldap_exists() (Bug #9235).
authorJan Schneider <jan@horde.org>
Mon, 13 Sep 2010 13:41:54 +0000 (15:41 +0200)
committerJan Schneider <jan@horde.org>
Mon, 13 Sep 2010 13:41:54 +0000 (15:41 +0200)
framework/Group/lib/Horde/Group/Ldap.php

index 357bd92..c5bd02e 100644 (file)
@@ -451,11 +451,11 @@ class Horde_Group_Ldap extends Horde_Group
             $group = $this->getGroupShortName($group);
 
             $res = @ldap_compare($this->_ds, $groupDN, $this->_params['gid'], $group);
-            if ($res === false) {
+            // $res is True if the group exists, false if not, -1 on error.
+            if ($res === -1) {
                 throw new Horde_Group_Exception(sprintf('Internal Error: An attribute must ALWAYS match itself: %s', @ldap_error($this->_ds)));
             }
-            // $res is True if the group exists, -1 if not, false never
-            $cache[$group] = ($res === true);
+            $cache[$group] = $res
         }
 
         return $cache[$group];