From 85c65818f638f0dbbc1c7b39571a54e428dda202 Mon Sep 17 00:00:00 2001 From: statiksof <42906766+statiksof@users.noreply.github.com> Date: Thu, 12 Nov 2020 13:17:16 +0100 Subject: [PATCH] Update ldapauthenticator.py --- ldapauthenticator/ldapauthenticator.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ldapauthenticator/ldapauthenticator.py b/ldapauthenticator/ldapauthenticator.py index 36f2e0d..a1d5849 100644 --- a/ldapauthenticator/ldapauthenticator.py +++ b/ldapauthenticator/ldapauthenticator.py @@ -12,7 +12,7 @@ class LDAPAuthenticator(Authenticator): - server_address = Unicode( + server_address = List( config=True, help=""" Address of the LDAP server to contact. @@ -305,14 +305,15 @@ def resolve_username(self, username_supplied_by_user): return (user_dn, response[0]["dn"]) def get_connection(self, userdn, password): - server = ldap3.Server( - self.server_address, port=self.server_port, use_ssl=self.use_ssl - ) + server_pool = ldap3.ServerPool(self.server_address, + ldap3.ROUND_ROBIN, + active=True, + exhaust=True) auto_bind = ( - ldap3.AUTO_BIND_NO_TLS if self.use_ssl else ldap3.AUTO_BIND_TLS_BEFORE_BIND + self.use_ssl and ldap3.AUTO_BIND_TLS_BEFORE_BIND or ldap3.AUTO_BIND_NO_TLS ) conn = ldap3.Connection( - server, user=userdn, password=password, auto_bind=auto_bind + server_pool, user=userdn, password=password, auto_bind=auto_bind ) return conn