@@ -33,7 +33,9 @@ class LDAPLockTimeout(Exception):
33
33
34
34
def e2c (entry ):
35
35
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
+ )
37
39
return cls (** dict (list ([("dn" , entry [0 ])] + list (entry [1 ].items ()))))
38
40
except NameError as dcerror :
39
41
print (f"dataclasses not supported" )
@@ -166,25 +168,29 @@ def __authenticate__(self):
166
168
raise ldap .INVALID_CREDENTIALS
167
169
168
170
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 } " )
188
194
189
195
def __enter__ (self ):
190
196
self .inUse = True
0 commit comments