Code

Added error reporting to ldap::generateLdif
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 08:54:56 +0000 (08:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 08:54:56 +0000 (08:54 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@20094 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc

index de41a10815740e87310ea98171225e713555463b..82263242cf1c083f78dadba92af413a19762b001 100644 (file)
@@ -884,12 +884,21 @@ class LDAP{
       }
       $scope = (!empty($scope))?' -s '.$scope: '';
 
+      // First check if we are able to call 'ldapsearch' on the command line.
+      $check = shell_exec('which ldapsearch');
+      if(empty($check)){
+        $this->error = sprintf(_("Missing command line programm '%s'!"), 'ldapsearch');
+        return(NULL);
+      }
+
       // Prepare parameters to be valid for shell execution
       $dn = escapeshellarg($dn);
       $pwd = $this->bindpw;
       $host = escapeshellarg($this->hostname);
       $admin = escapeshellarg($this->binddn);
       $filter = escapeshellarg($filter);
+
+        
       $cmd = "ldapsearch -x -LLLL -D {$admin} {$filter} {$limit} {$scope} -H {$host} -b {$dn} -W ";
 
       // Create list of process pipes
@@ -913,7 +922,8 @@ class LDAP{
 
           // Close the process and check its return value
           if(proc_close($process) != 0){
-              trigger_error($err);
+              $this->error = $err;
+              return(NULL);
           }
       }
       return($res);