diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 980464e7152c3dfc301f7608f3527308b56b3fdf..a008f2a1f35b85c912e38176c6d98be3719c54fa 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -732,7 +732,7 @@ sub get_ldap_connexion {
   # read ldap's server's info from /etc/fusiondirectory/fusiondirectory.conf
   if (-e $fd_config) {
     my $twig = XML::Twig->new();    # create the twig
-    $twig->parsefile($fd_config); # build it
+    $twig->safe_parsefile($fd_config) or die("There is an error in $fd_config XML code: ".(split /\n/, $@)[1]."\n");
     my @locs = $twig->root->first_child('main')->children('location');
     my %locations = ();
     foreach my $loc (@locs) {