catch ( Exception e )
{
// Something went wrong. Write back an error message
// For BindRequest, it should be an InvalidCredentials,
// no matter what kind of exception we got.
ResultCodeEnum code = null;
LdapResult result = bindRequest.getResultResponse().getLdapResult();
if ( e instanceof LdapUnwillingToPerformException )
{
code = ResultCodeEnum.UNWILLING_TO_PERFORM;
result.setResultCode( code );
}
else if ( e instanceof LdapInvalidDnException )
{
code = ResultCodeEnum.INVALID_DN_SYNTAX;
result.setResultCode( code );
}
else
{
code = ResultCodeEnum.INVALID_CREDENTIALS;
result.setResultCode( code );
}
String msg = code.toString() + ": Bind failed: " + e.getLocalizedMessage();
if ( LOG.isDebugEnabled() )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
msg += "\n\nBindRequest = \n" + bindRequest.toString();