1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-25 10:44:30 +01:00

fix logging in ldap backend

This commit is contained in:
kakwa 2015-05-26 23:12:33 +02:00
parent 9d314b6778
commit 746c2a9978

View File

@ -72,9 +72,12 @@ class Backend(ldapcherry.backend.Backend):
def set_attrs(self, attrs): def set_attrs(self, attrs):
pass pass
def rm_from_group(self,username): def rm_from_group(self, username):
pass pass
def get_groups(self, username):
return []
def add_user(self, attrs): def add_user(self, attrs):
ldap_client = self._bind() ldap_client = self._bind()
attrs_str = {} attrs_str = {}
@ -89,23 +92,23 @@ class Backend(ldapcherry.backend.Backend):
info = e[0]['info'] info = e[0]['info']
desc = e[0]['desc'] desc = e[0]['desc']
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"Configuration error, " + desc + ", " + info, msg = "Configuration error, " + desc + ", " + info,
) )
raise e raise e
except ldap.INSUFFICIENT_ACCESS as e: except ldap.INSUFFICIENT_ACCESS as e:
info = e[0]['info'] info = e[0]['info']
desc = e[0]['desc'] desc = e[0]['desc']
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"Access error, " + desc + ", " + info, msg = "Access error, " + desc + ", " + info,
) )
raise e raise e
except ldap.ALREADY_EXISTS as e: except ldap.ALREADY_EXISTS as e:
desc = e[0]['desc'] desc = e[0]['desc']
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"adding user failed, " + desc, msg = "adding user failed, " + desc,
) )
raise e raise e
@ -123,15 +126,15 @@ class Backend(ldapcherry.backend.Backend):
ldap_client.simple_bind_s(self.binddn, self.bindpassword) ldap_client.simple_bind_s(self.binddn, self.bindpassword)
except ldap.INVALID_CREDENTIALS as e: except ldap.INVALID_CREDENTIALS as e:
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"Configuration error, wrong credentials, unable to connect to ldap with '" + self.binddn + "'", msg = "Configuration error, wrong credentials, unable to connect to ldap with '" + self.binddn + "'",
) )
ldap_client.unbind_s() ldap_client.unbind_s()
raise e raise e
except ldap.SERVER_DOWN as e: except ldap.SERVER_DOWN as e:
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"Unable to contact ldap server '" + self.uri + "', check 'auth.ldap.uri' and ssl/tls configuration", msg = "Unable to contact ldap server '" + self.uri + "', check 'auth.ldap.uri' and ssl/tls configuration",
) )
ldap_client.unbind_s() ldap_client.unbind_s()
raise e raise e
@ -148,8 +151,8 @@ class Backend(ldapcherry.backend.Backend):
) )
except ldap.FILTER_ERROR as e: except ldap.FILTER_ERROR as e:
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"Bad search filter, check '" + self.backend_name + ".*_filter_tmpl' params", msg = "Bad search filter, check '" + self.backend_name + ".*_filter_tmpl' params",
) )
ldap_client.unbind_s() ldap_client.unbind_s()
raise e raise e
@ -219,8 +222,8 @@ class Backend(ldapcherry.backend.Backend):
ldap_client.start_tls_s() ldap_client.start_tls_s()
except ldap.OPERATIONS_ERROR as e: except ldap.OPERATIONS_ERROR as e:
self._logger( self._logger(
logging.ERROR, severity = logging.ERROR,
"cannot use starttls with ldaps:// uri (uri: " + self.uri + ")", msg = "cannot use starttls with ldaps:// uri (uri: " + self.uri + ")",
) )
raise e raise e
#raise cherrypy.HTTPError("500", "Configuration Error, contact administrator") #raise cherrypy.HTTPError("500", "Configuration Error, contact administrator")