Code

Updated ldap export
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 09:01:01 +0000 (09:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 09:01:01 +0000 (09:01 +0000)
-Added error handling

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

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

index ee057e6bc82ade87c2c39471389d7ba77beff74c..b541b5214626dd267644946c0eb613a4c49eba01 100644 (file)
@@ -84,17 +84,32 @@ 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=*',$scope);
-                send_binary_content($data,$name);
+
+                // 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=*',$scope);
+                    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);
+                    }
+                }
             }
         }
-
+    
         // Show the main form
         return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
     }