mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
fix backend name (collision with libraries name)
This commit is contained in:
parent
b67e0112c5
commit
1ac474647b
@ -14,6 +14,7 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
|
|
||||||
def __init__(self, config, logger):
|
def __init__(self, config, logger):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self._logger = logger
|
||||||
|
|
||||||
def auth(self, username, password):
|
def auth(self, username, password):
|
||||||
|
|
||||||
@ -52,13 +53,13 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
except ldap.INVALID_CREDENTIALS:
|
except ldap.INVALID_CREDENTIALS:
|
||||||
self._logger(
|
self._logger(
|
||||||
logging.ERROR,
|
logging.ERROR,
|
||||||
"Configuration error, wrong credentials, unable to connect to ldap with '" + self.binddn + "'"
|
"Configuration error, wrong credentials, unable to connect to ldap with '" + self.config['binddn'] + "'"
|
||||||
)
|
)
|
||||||
raise cherrypy.HTTPError("500", "Configuration Error, contact administrator")
|
raise cherrypy.HTTPError("500", "Configuration Error, contact administrator")
|
||||||
except ldap.SERVER_DOWN:
|
except ldap.SERVER_DOWN:
|
||||||
self._logger(
|
self._logger(
|
||||||
logging.ERROR,
|
logging.ERROR,
|
||||||
"Unable to contact ldap server '" + self.uri + "', check 'auth.ldap.uri' and ssl/tls configuration"
|
"Unable to contact ldap server '" + self.config['uri'] + "', check 'auth.ldap.uri' and ssl/tls configuration"
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -84,9 +85,9 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
ldap.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
ldap.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
||||||
if self.config['starttls'] == 'on':
|
if self.config['starttls'] == 'on':
|
||||||
ldap.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
ldap.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
||||||
if self.ca:
|
if self.config['ca']:
|
||||||
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self.config['ca'])
|
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self.config['ca'])
|
||||||
if self.checkcert == 'off':
|
if self.config['checkcert'] == 'off':
|
||||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
|
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
|
||||||
else:
|
else:
|
||||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,ldap.OPT_X_TLS_DEMAND)
|
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,ldap.OPT_X_TLS_DEMAND)
|
||||||
@ -97,7 +98,7 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
except ldap.OPERATIONS_ERROR:
|
except ldap.OPERATIONS_ERROR:
|
||||||
self._logger(
|
self._logger(
|
||||||
logging.ERROR,
|
logging.ERROR,
|
||||||
"cannot use starttls with ldaps:// uri (uri: " + self.uri + ")"
|
"cannot use starttls with ldaps:// uri (uri: " + self.config['uri'] + ")"
|
||||||
)
|
)
|
||||||
raise cherrypy.HTTPError("500", "Configuration Error, contact administrator")
|
raise cherrypy.HTTPError("500", "Configuration Error, contact administrator")
|
||||||
return ldap_client
|
return ldap_client
|
Loading…
Reference in New Issue
Block a user