Skip to content

Commit 7535349

Browse files
jfleming-icsmiklosovic
authored andcommitted
Add debug message when an exception is encountered on LDAP retrive call
1 parent 359fdc5 commit 7535349

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

base/src/main/java/com/instaclustr/cassandra/ldap/auth/DefaultLDAPServer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String searchLdapDN(final String username) throws NamingException
104104
final String filterTemplate = properties.getProperty(LdapAuthenticatorConfiguration.FILTER_TEMPLATE);
105105
final String filter = format(filterTemplate, username);
106106

107-
logger.debug(String.format("User name is %s, going to use filter: %s", username, filter));
107+
logger.debug("User name is {}, going to use filter: {}", username, filter);
108108

109109
String dn = null;
110110

@@ -133,7 +133,7 @@ public String searchLdapDN(final String username) throws NamingException
133133
+ "User likely does not exist or connection to LDAP server is invalid.", filter, resolvedDns));
134134
}
135135

136-
logger.debug("Returning DN: " + resolvedDns.get(0));
136+
logger.debug("Returning DN: {}", resolvedDns.get(0));
137137

138138
return dn;
139139
} catch (final NamingException ex)
@@ -186,7 +186,7 @@ public User retrieve(User user) throws LDAPAuthFailedException
186186
{
187187
final String ldapDn = context.searchLdapDN(user.getUsername());
188188

189-
logger.debug(String.format("Resolved LDAP DN: %s", ldapDn));
189+
logger.debug("Resolved LDAP DN: {}", ldapDn);
190190

191191
final Hashtable<String, String> env = getUserEnv(ldapDn,
192192
user.getPassword(),
@@ -195,7 +195,7 @@ public User retrieve(User user) throws LDAPAuthFailedException
195195

196196
try (final CloseableLdapContext ldapContext = new CloseableLdapContext(new InitialDirContext(env)))
197197
{
198-
logger.debug("Logging to LDAP with {} was ok!", user.toString());
198+
logger.debug("Logging to LDAP with {} was ok!", user);
199199

200200
final User foundUser = new User(user.getUsername(),
201201
hasher.hashPassword(user.getPassword(),
@@ -211,6 +211,7 @@ public User retrieve(User user) throws LDAPAuthFailedException
211211
}
212212
catch (final Exception ex)
213213
{
214+
logger.debug("Error encountered when authenticating via LDAP {}", ex.getMessage());
214215
throw new LDAPAuthFailedException(ExceptionCode.UNAUTHORIZED, "Not possible to login " + user.getUsername(), ex);
215216
}
216217
}

0 commit comments

Comments
 (0)