Skip to content

Commit 0d2076f

Browse files
author
Kota Tsuyuzaki
committed
Add connect_timeout option for LDAP connection
That option will enable the LDAP client to give up to connect to the server in the specific seconds.
1 parent a9d2aa9 commit 0d2076f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ldapauthenticator/ldapauthenticator.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ def _server_port_default(self):
234234
help="""
235235
Comma separated address:port of the LDAP server which can be tried to contact when
236236
primary LDAP server is unavailable.
237-
237+
""",
238+
)
239+
connect_timeout = Int(
240+
config=True,
241+
default=15,
242+
help="""
243+
LDAP client connect timeout (seconds)
238244
""",
239245
)
240246

@@ -338,7 +344,10 @@ def get_connection(self, userdn, password):
338344

339345
def _get_real_connection(self, userdn, password, server_address, server_port):
340346
server = ldap3.Server(
341-
server_address, port=server_port, use_ssl=self.use_ssl
347+
server_address,
348+
port=server_port,
349+
use_ssl=self.use_ssl,
350+
connect_timeout=self.connect_timeout,
342351
)
343352
auto_bind = (
344353
ldap3.AUTO_BIND_NO_TLS if self.use_ssl else ldap3.AUTO_BIND_TLS_BEFORE_BIND

0 commit comments

Comments
 (0)