LdapContext ctx = null;
try {
ctx = ldapContextFactory.getLdapContext(user, pass);
}
catch (javax.naming.AuthenticationException e) {
throw new AuthenticationException("User '" + user + "' cannot be authenticated.", e);
}
catch (NamingException e) {
throw new AuthenticationException("User '" + user + "' cannot be authenticated.", e);
}
finally {
LdapUtils.closeContext(ctx);
}
}