mirror of
https://github.com/jdupouy/radicale3-auth-ldap.git
synced 2024-10-27 19:14:00 +00:00
corrected multi ldap server handling
This commit is contained in:
parent
b71adb30ec
commit
a3b2e41864
@ -37,7 +37,14 @@ import radicale_auth_ldap.ldap3imports
|
||||
class Auth(BaseAuth):
|
||||
def is_authenticated(self, user, password):
|
||||
"""Check if ``user``/``password`` couple is valid."""
|
||||
SERVER = ldap3.Server(self.configuration.get("auth", "ldap_url"))
|
||||
server_list = self.configuration.get("auth", "ldap_url")
|
||||
if ' ' in server_list: # Handle for multiple LDAP server defined in ldap_url with space separation
|
||||
servers = server_list.split(' ')
|
||||
SERVER = ldap3.ServerPool(None)
|
||||
for s in servers:
|
||||
SERVER.add(ldap3.Server(s))
|
||||
else: # only one server is defined
|
||||
SERVER = ldap3.Server(server_list)
|
||||
BASE = self.configuration.get("auth", "ldap_base")
|
||||
ATTRIBUTE = self.configuration.get("auth", "ldap_attribute")
|
||||
FILTER = self.configuration.get("auth", "ldap_filter")
|
||||
@ -46,9 +53,6 @@ class Auth(BaseAuth):
|
||||
SCOPE = self.configuration.get("auth", "ldap_scope")
|
||||
SUPPORT_EXTENDED = self.configuration.getboolean("auth", "ldap_support_extended", fallback=True)
|
||||
|
||||
if ' ' in SERVER: # Handle if multiple LDAP server is defined in ldap_url with space separation
|
||||
SERVER = SERVER.split(' ') # ldap3.connection can handle multiple servers in a list as an implicit server pool
|
||||
|
||||
if BINDDN and PASSWORD:
|
||||
conn = ldap3.Connection(SERVER, BINDDN, PASSWORD)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user