Catch and show LDAP perl error
authorJamie Cameron <jcameron@webmin.com>
Sat, 2 May 2009 00:13:36 +0000 (00:13 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 2 May 2009 00:13:36 +0000 (00:13 +0000)
ldap-client/lang/en
ldap-client/ldap-client-lib.pl

index 235f036..931e0bf 100644 (file)
@@ -110,6 +110,7 @@ ldap_emodule=The $1 Perl module needed for talking to the LDAP server is not ins
 ldap_emodule2=The $1 Perl module needed for talking to the LDAP server is not installed.
 ldap_econf=The LDAP client configuration file $1 was not found on your system
 ldap_econn=Failed to connect to LDAP server $1 port $2
+ldap_econn2=Failed to connect to LDAP server $1 port $2 : $3
 ldap_elogin=Failed to bind to LDAP server $1 as $2 : $3
 ldap_anon=anonymous
 ldap_eparse=Could not parse the LDAP server URI $1
index 3652eb7..218f91a 100644 (file)
@@ -200,9 +200,16 @@ if ($ldap_hosts) {
                      &find_svalue("port", $conf) ||
                      ($use_ssl == 1 ? 636 : 389);
        foreach my $host (@hosts) {
-               $ldap = Net::LDAP->new($host, port => $port,
+               eval {
+                       $ldap = Net::LDAP->new($host, port => $port,
                                scheme => $use_ssl == 1 ? 'ldaps' : 'ldap');
-               if (!$ldap) {
+                       };
+               if ($@) {
+                       $err = &text('ldap_econn2',
+                                    "<tt>$host</tt>", "<tt>$port</tt>",
+                                    &html_escape($@));
+                       }
+               elsif (!$ldap) {
                        $err = &text('ldap_econn',
                                     "<tt>$host</tt>", "<tt>$port</tt>");
                        }