]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 367480: [LDAP] Try a list of servers in order until we connect successfully
authormkanat%bugzilla.org <>
Thu, 8 Mar 2007 02:43:43 +0000 (02:43 +0000)
committermkanat%bugzilla.org <>
Thu, 8 Mar 2007 02:43:43 +0000 (02:43 +0000)
Patch By Tony Bajan <firefox@tonyb.me.uk> r=mkanat, a=mkanat

Bugzilla/Auth/Verify/LDAP.pm
template/en/default/admin/params/ldap.html.tmpl
template/en/default/global/code-error.html.tmpl

index 343f7952cd4dbbd4552af106fdcb9ecd70444c18..0176abdcb31e1873c8d94052bbe2f5e904db23f4 100644 (file)
@@ -37,6 +37,7 @@ use fields qw(
 
 use Bugzilla::Constants;
 use Bugzilla::Error;
+use Bugzilla::Util;
 
 use Net::LDAP;
 
@@ -134,11 +135,15 @@ sub ldap {
     my ($self) = @_;
     return $self->{ldap} if $self->{ldap};
 
-    my $server = Bugzilla->params->{"LDAPserver"};
-    ThrowCodeError("ldap_server_not_defined") unless $server;
+    my @servers = split(/[\s,]+]/, Bugzilla->params->{"LDAPserver"});
+    ThrowCodeError("ldap_server_not_defined") unless @servers;
 
-    $self->{ldap} = new Net::LDAP($server)
-        || ThrowCodeError("ldap_connect_failed", { server => $server });
+    foreach (@servers) {
+        $self->{ldap} = new Net::LDAP(trim($_));
+        last if $self->{ldap};
+    }
+    ThrowCodeError("ldap_connect_failed", { server => join(", ", @servers) }) 
+        unless $self->{ldap};
 
     # try to start TLS if needed
     if (Bugzilla->params->{"LDAPstarttls"}) {
index a3c7e464357f47e88d87a932b323b995470b781d..22375cdf70e73a5fc1e3b1f67044a8eb857de6be 100644 (file)
@@ -30,7 +30,9 @@
                 "URI syntax can also be used, such as "_
                 "ldaps://ldap.company.com (for a secure connection) or " _
                 "ldapi://%2fvar%2flib%2fldap_sock (for a socket-based " _
-                "local connection.",
+                "local connection. Multiple hostnames or URIs can be comma " _
+                "separated; each will be tried in turn until a connection is " _
+                "established.",
 
   LDAPstartls => "Whether to require encrypted communication once normal " _
                  "LDAP connection achieved with the server.",
index 2de8bd6a26c152dcdc2286a4af4ea8897a2267ec..91044064d1b364236dcdc440450c06cb35f28f71 100644 (file)
     The specified LDAP attribute [% attr FILTER html %] was not found.
 
   [% ELSIF error == "ldap_connect_failed" %]
-    Could not connect to the LDAP server <code>[% server FILTER html %]</code>.
+    Could not connect to the LDAP server(s) <code>[% server FILTER html %]</code>.
 
   [% ELSIF error == "ldap_start_tls_failed" %]
     Could not start TLS with LDAP server: <code>[% error FILTER html %]</code>.