Skip to content

Commit

Permalink
UBO-363 Fixed NullPointerException in MCRUserMatcherLDAP (#426)
Browse files Browse the repository at this point in the history
* UBO-363 Fixed NullPointerException in MCRUserMatcherLDAP

* UBO-363 Improved logging of exceptions
  • Loading branch information
Possommi authored Oct 24, 2024
1 parent 2c86acb commit 821a230
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ private LdapContext getLDAPContext(String uid, String credentials, String dn) th
return new InitialLdapContext(env, null);
} catch (AuthenticationException ex) {
if (ex.getMessage().contains(PATTERN_INVALID_CREDENTIALS)) {
LOGGER.info("Could not authenticate LDAP user " + uid + ": " + ex.getMessage());
return null;
LOGGER.error("Could not authenticate LDAP user {}:{}", uid, ex.getMessage());
} else {
throw ex;
LOGGER.error("Error while creating {}", LdapContext.class.getSimpleName(), ex);
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,18 @@ public List<LDAPObject> getLDAPUsersByGivenLDAPAttributes(Multimap ldapAttribute
String ldapSearchFilter = createLDAPSearchFilter(ldapAttributes, searchTemplate);
try {
ctx = new LDAPAuthenticator().authenticate();
if (ctx == null) {
return new ArrayList<>();
}
ldapUsers = new LDAPSearcher().searchWithGlobalDN(ctx, ldapSearchFilter);
} catch (NamingException ex) {
LOGGER.error("Exception occurred: " + ex);
LOGGER.error("Exception occurred during getting LDAP users", ex);
} finally {
if (ctx != null) {
try {
ctx.close();
} catch (NamingException ex) {
LOGGER.warn("could not close context " + ex);
LOGGER.warn("Could not close LDAP context", ex);
}
}
}
Expand Down

0 comments on commit 821a230

Please sign in to comment.