Commit ca29f042 authored by Lorenz Steinert's avatar Lorenz Steinert

fix ldap connection error in __init__

parent 8725ff32
......@@ -56,7 +56,6 @@ def resort_fsr(fsr, num_cols=5):
class FsrLdap:
"""Class die die protokoll .tex datei erstellt"""
def __init__(self, server, base, share_dir, config, debug=False, timeout=1, testing=None):
self.debug = debug
......@@ -66,7 +65,12 @@ class FsrLdap:
self.conn = ldap.Connection(self.server)
else:
self.conn = ldap.Connection(self.server, client_strategy=ldap.MOCK_SYNC)
self.conn.bind()
try:
self.conn.bind()
except ldap.core.exceptions.LDAPSocketOpenError:
pass
self.base = base
self.share_dir = share_dir
self.config = config
......@@ -160,12 +164,12 @@ class FsrLdap:
fsr = self._get_fsr_ldap()
if isinstance(fsr, tuple):
pass
fsr = fsr[0]
elif isinstance(fsr, Flag):
if fsr == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
if isinstance(fsr, Error):
if fsr & (Error.UNSEC_SEARCH | Error.LDAP_FAIL) and not gen_fallback:
fsr = self._get_fallback_fsr(share_dir)
if fsr == Error.NO_FILE | Error.UNSEC_SEARCH:
if isinstance(fsr, Error):
if fsr & (Error.NO_FILE | Error.UNSEC_SEARCH):
fsr = []
return resort_fsr(fsr)
......@@ -215,10 +219,11 @@ class FsrLdap:
if isinstance(fsr_extern, tuple):
pass
fsr_extern = fsr_extern[0]
if isinstance(fsr_extern, Flag):
if fsr_extern == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
if isinstance(fsr_extern, Error):
if fsr_extern & (Error.UNSEC_SEARCH | Error.LDAP_FAIL) and not gen_fallback:
fsr_extern = self._get_fallback_fsr_extern(share_dir)
if fsr_extern == Error.NO_FILE | Error.UNSEC_SEARCH:
if isinstance(fsr_extern, Error):
if fsr_extern & (Error.NO_FILE | Error.UNSEC_SEARCH):
fsr_extern = []
return resort_fsr(fsr_extern)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment