From f9dbd00f0a1e413e000e42b968de0f6a0a44558f Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Mon, 26 Mar 2018 22:30:54 +0200
Subject: [PATCH] Add support for multiple ad hosts

---
 auth.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/auth.py b/auth.py
index 7130963..12744c5 100644
--- a/auth.py
+++ b/auth.py
@@ -155,8 +155,16 @@ try:
             if ca_cert is not None:
                 tls_config = ldap3.Tls(
                     validate=ssl.CERT_REQUIRED, ca_certs_file=ca_cert)
-            self.server = ldap3.Server(
-                host, port=port, use_ssl=use_ssl, tls=tls_config)
+            if isinstance(host, str):
+                self.server = ldap3.Server(
+                    host, port=port, use_ssl=use_ssl, tls=tls_config)
+            else:
+                hosts = host
+                self.server = ldap3.ServerPool([
+                    ldap3.Server(
+                        host, port=port, use_ssl=use_ssl, tls=tls_config)
+                    for host in hosts
+                ], ldap3.FIRST)
             self.domain = domain
             self.user_dn = user_dn
             self.group_dn = group_dn
-- 
GitLab