Reputation: 118
While trying to login to an ldap server with an expired password an exception is thrown in the logging.
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 773, v1db0
I want to give the user a corresponding message, but i'm not able to catch that exception. (how can i get the exception that's shown in the logging ? because data 773 means the password is expired
CallbackHandler handler = new UsernamePasswordHandler(
username, password);
LoginContext lc = new LoginContext(applicationPolicyName,
handler);
try {
lc.login();
} catch (Exception){
log.warn(e.getMessage());
}
Upvotes: 0
Views: 639
Reputation: 2581
assuming that what you want to catch are those of type javax.naming.AuthenticationException, you can put it in a try catch block as:
try {
lc.login();
} catch(AuthenticationException e) {
processError(e.getMessage());
}
...
private void processError(String errorMessage) {
if (errorMessage.contains("data 773")) {
// then do your stuff here like add error message as label etc
}
}
Upvotes: 1
Reputation: 719248
You need to get hold of the exception stack trace. (If necessary, change your logging configs so that the stacktrace is written to the logs.)
That will tell you where the exception is being thrown.
Then examine the source code to see where it is being caught and logged, and see if there is any of your code upstack that could catch it first.
Upvotes: 1