gunnar: server/php-kolab/Kolab_Webadmin/Webadmin auth.class.php, 1.3, 1.4 ldap.class.php, 1.7, 1.8

cvs at kolab.org cvs at kolab.org
Wed Aug 22 09:44:11 CEST 2007


Author: gunnar

Update of /kolabrepository/server/php-kolab/Kolab_Webadmin/Webadmin
In directory doto:/tmp/cvs-serv2824/Kolab_Webadmin/Webadmin

Modified Files:
	auth.class.php ldap.class.php 
Log Message:
Fixed some errors in the ldap class.

Index: auth.class.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Webadmin/Webadmin/auth.class.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- auth.class.php	17 Aug 2007 05:15:44 -0000	1.3
+++ auth.class.php	22 Aug 2007 07:44:08 -0000	1.4
@@ -33,6 +33,7 @@
  */
 
 require_once('debug.php');
+require_once('group.class.php');
 
 class KolabAuth {
     function KolabAuth( $ldap, $params = array() ) {

Index: ldap.class.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Webadmin/Webadmin/ldap.class.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ldap.class.php	22 Aug 2007 07:15:25 -0000	1.7
+++ ldap.class.php	22 Aug 2007 07:44:08 -0000	1.8
@@ -159,6 +159,15 @@
     }
 
     /**
+     * Get the last LDAP error number
+     *
+     * @return int The last LDAP error number
+     */
+    function errno() {
+        return ldap_errno($this->_ldap);
+    }
+
+    /**
      * Escape LDAP values
      *
      * @param string $str The string to escape
@@ -398,10 +407,9 @@
      */
     function getObjectClasses($dn) {
         $ldap_object = $this->_ldap->read($dn);
-        if( !$ldap_object ) {
+        if( !$ldap_object && $this->errno()) {
             return PEAR::raiseError(sprintf(_("LDAP Error: No such dn: %s: %s"), 
-                                            $dn, 
-                                            ldap_error($this->_ldap->connection)));
+                                            $dn, $this->error()));
         }
         unset($ldap_object['count']);
         return $ldap_object['objectClass'];
@@ -470,14 +478,18 @@
      *
      * @param array $result The LDAP search result
      *
-     * @return mixed The DN or a PEAR error
+     * @return mixed The DN, false or a PEAR error
      */
     function dnFromResult($result) {
-        $entry = @ldap_first_entry($result);
+        $entry = @ldap_first_entry($this->_ldap, $result);
+        if (!$entry && $this->errno()) {
+            return PEAR::raiseError(sprintf(_("Search result contained no entries. Error was: %s"),
+                                            $this->error()));
+        }
         if (!$entry) {
-            return PEAR::raiseError(_('Search result contained no entries'));
+            return false;
         }
-        return ldap_get_dn($entry);
+        return ldap_get_dn($this->_ldap, $entry);
     }
     
     /**





More information about the commits mailing list