# HG changeset patch # User Raoul Thill # Date 1349960747 -7200 # Node ID f89bb8545a618ebd87f8bbecbae00041a7ea7808 # Parent 1cd1cbe6cdcce8b5f0622edf740e344bb39e0b1c LDAP fail-over using multiple server addresses from host field seperated by comma. diff -r 1cd1cbe6cdcc -r f89bb8545a61 rhodecode/lib/auth_ldap.py --- 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)