From f2c0602e09ac52e20f12be88128168b4b210999a Mon Sep 17 00:00:00 2001 From: Dennis Buchhorn Date: Wed, 6 Dec 2023 20:45:17 +0100 Subject: [PATCH] feat[__init__.py]: add more logging --- radicale-auth-ldap/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/radicale-auth-ldap/__init__.py b/radicale-auth-ldap/__init__.py index bc393fd..7a6ec96 100644 --- a/radicale-auth-ldap/__init__.py +++ b/radicale-auth-ldap/__init__.py @@ -44,16 +44,21 @@ class Auth(BaseAuth): accessGroupFilter = self.configuration.get("auth", "ldap_access_group_filter") accessGroupAttribute = self.configuration.get("auth", "ldap_access_group_attribute") - logger.debug("LDAP: start connection") + logger.info("LDAP: start connection") + logger.debug("LDAP: server URL: %s" % serverUrl) + logger.debug("LDAP: binddn: %s" % binddn) + logger.debug("LDAP: secret: %s" % secret) ## TODO: check for errors server = ldap3.Server(serverUrl) conn = ldap3.Connection(server, binddn, secret) conn.bind() result = conn.result + logger.info("LDAP: connection successful") logger.debug("LDAP bind result: %s" % str(result)) if result['description'] == "invalidCredentials": + logger.warning("LDAP: binddn credentials are invalid") return "" if accessGroupFilter: @@ -73,10 +78,10 @@ class Auth(BaseAuth): accessGroupDn = conn.response[0]['dn'] logger.debug("LDAP access group DN: %s" % accessGroupDn) else: - logger.debug("LDAP: ERROR: more than 1 group found") + logger.warning("LDAP: more than 1 group found") return "" else: - logger.debug("LDAP: ERROR: no group found") + logger.warning("LDAP: no group found") return "" logger.debug("LDAP user filter: %s" % userFilter) @@ -110,10 +115,10 @@ class Auth(BaseAuth): logger.debug("LDAP: user is NOT in access group") return "" else: - logger.debug("LDAP: ERROR: more than 1 user found") + logger.warning("LDAP: more than 1 user found") return "" else: - logger.debug("LDAP: ERROR: no user found") + logger.warning("LDAP: no user found") return "" logger.debug("LDAP: restart connection for user") @@ -126,6 +131,8 @@ class Auth(BaseAuth): logger.debug("LDAP bind result: %s" % str(result)) if result['description'] == "invalidCredentials": + logger.warning("LDAP: user credentials are invalid") return "" else: + logger.info("LDAP: user successful verified") return userAttributeValue