changeset 2915:f89bb8545a61 beta

LDAP fail-over using multiple server addresses from host field seperated by comma.
author Raoul Thill <raoul.thill@gmail.com>
date Thu, 11 Oct 2012 15:05:47 +0200
parents 1cd1cbe6cdcc
children f6685a62e455
files rhodecode/lib/auth_ldap.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/auth_ldap.py	Tue Oct 09 21:39:26 2012 +0200
+++ b/rhodecode/lib/auth_ldap.py	Thu Oct 11 15:05:47 2012 +0200
@@ -57,17 +57,19 @@
         OPT_X_TLS_DEMAND = 2
         self.TLS_REQCERT = getattr(ldap, 'OPT_X_TLS_%s' % tls_reqcert,
                                    OPT_X_TLS_DEMAND)
-        self.LDAP_SERVER_ADDRESS = server
+        # split server into list
+        self.LDAP_SERVER_ADDRESS = server.split(',')
         self.LDAP_SERVER_PORT = port
 
         # USE FOR READ ONLY BIND TO LDAP SERVER
         self.LDAP_BIND_DN = safe_str(bind_dn)
         self.LDAP_BIND_PASS = safe_str(bind_pass)
-
-        self.LDAP_SERVER = "%s://%s:%s" % (ldap_server_type,
-                                           self.LDAP_SERVER_ADDRESS,
-                                           self.LDAP_SERVER_PORT)
-
+        _LDAP_SERVERS = []
+        for host in self.LDAP_SERVER_ADDRESS:
+            _LDAP_SERVERS.append("%s://%s:%s" % (ldap_server_type,
+                                                     host.replace(' ', ''),
+                                                     self.LDAP_SERVER_PORT))
+        self.LDAP_SERVER = str(', '.join(s for s in _LDAP_SERVERS))
         self.BASE_DN = safe_str(base_dn)
         self.LDAP_FILTER = safe_str(ldap_filter)
         self.SEARCH_SCOPE = getattr(ldap, 'SCOPE_%s' % search_scope)