Skip to content

Commit e5e335b

Browse files
committed
some ldap options are not available < 3.9
1 parent 1140996 commit e5e335b

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

Lib/ldappool/__init__.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class LDAPLockTimeout(Exception):
3333

3434
def e2c(entry):
3535
try:
36-
cls = dataclasses.make_dataclass("", ["dn"] + list(entry[1].keys()), frozen=True)
36+
cls = dataclasses.make_dataclass(
37+
"", ["dn"] + list(entry[1].keys()), frozen=True
38+
)
3739
return cls(**dict(list([("dn", entry[0])] + list(entry[1].items()))))
3840
except NameError as dcerror:
3941
print(f"dataclasses not supported")
@@ -166,25 +168,29 @@ def __authenticate__(self):
166168
raise ldap.INVALID_CREDENTIALS
167169

168170
def __set_connection_parameters__(self):
169-
self._conn.set_option(ldap.OPT_REFERRALS, self.params.get("referrals", False))
170-
self._conn.set_option(
171-
ldap.OPT_NETWORK_TIMEOUT, self.params.get("network_timeout", 10.0)
172-
)
173-
self._conn.set_option(ldap.OPT_TIMEOUT, self.params.get("timeout", 10.0))
174-
self._conn.set_option(
175-
ldap.OPT_X_KEEPALIVE_IDLE, self.params.get("keepalive_idle", 10)
176-
)
177-
self._conn.set_option(
178-
ldap.OPT_X_KEEPALIVE_INTERVAL, self.params.get("keepalive_interval", 5)
179-
)
180-
self._conn.set_option(
181-
ldap.OPT_X_KEEPALIVE_PROBES, self.params.get("keepalive_probes", 3)
182-
)
183-
self._conn.set_option(ldap.OPT_RESTART, ldap.OPT_ON)
184-
if self.params.get("allow_tls_fallback", False):
185-
logging.debug("TLS Fallback enabled in LDAP")
186-
self._conn.set_option(ldap.OPT_X_TLS_TRY, 1)
187-
self._conn.set_option(ldap.OPT_X_TLS_NEWCTX, ldap.OPT_OFF)
171+
try:
172+
self._conn.set_option(
173+
ldap.OPT_REFERRALS, self.params.get("referrals", False)
174+
)
175+
self._conn.set_option(
176+
ldap.OPT_NETWORK_TIMEOUT, self.params.get("network_timeout", 10.0)
177+
)
178+
self._conn.set_option(ldap.OPT_TIMEOUT, self.params.get("timeout", 10.0))
179+
self._conn.set_option(
180+
ldap.OPT_X_KEEPALIVE_IDLE, self.params.get("keepalive_idle", 10)
181+
)
182+
self._conn.set_option(
183+
ldap.OPT_X_KEEPALIVE_INTERVAL, self.params.get("keepalive_interval", 5)
184+
)
185+
self._conn.set_option(
186+
ldap.OPT_X_KEEPALIVE_PROBES, self.params.get("keepalive_probes", 3)
187+
)
188+
self._conn.set_option(ldap.OPT_RESTART, ldap.OPT_ON)
189+
if self.params.get("allow_tls_fallback", False):
190+
self._conn.set_option(ldap.OPT_X_TLS_TRY, 1)
191+
self._conn.set_option(ldap.OPT_X_TLS_NEWCTX, ldap.OPT_OFF)
192+
except Exception as connerr:
193+
logging.error(f"cannot set LDAP option {connerr}")
188194

189195
def __enter__(self):
190196
self.inUse = True

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy