Code

Added error handling to ldap export class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 08:55:45 +0000 (08:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 08:55:45 +0000 (08:55 +0000)
-Once the generateLdif method failed, we just received an empty file.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@20095 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/ldapmanager/addons/ldapmanager/class_export.inc

index 466ff2239996e54111cc6c89eac10152d5b3e66c..8f1262b40bc3c2ddc36f978fbcbb2a5de510d405 100644 (file)
@@ -80,14 +80,21 @@ class ldifexport extends plugin
         }
 
         if(!empty($dn)){
+
             // Check permissions before sending the output
             if(!preg_match("/r/",$acls)){
                 msg_dialog::display(_("Permission error"), 
                         sprintf(_("You have no permission to export %s!"), bold(LDAP::fix($dn))),
                         ERROR_DIALOG);
             }else{
-                $data = $ldap->generateLdif(LDAP::fix($dn), 'objectClass=*',array(),$scope);
-                send_binary_content($data,$name);
+                $data = $ldap->generateLdif(LDAP::fix($dn), 'objectClass=*',array(),$scope, $limit=0);
+                if($data === NULL){
+                    msg_dialog::display(_("Error"), 
+                            sprintf(_("Failed to generate ldap export, error was '%s'!"), $ldap->get_error()),
+                            ERROR_DIALOG);
+                }else{
+                    send_binary_content($data,$name);
+                }
             }
         }