Le 10/04/2017 à 12:46, Maiorano Pasquale a écrit :
> Dear Sirs,
> I have the following problem: If I bind a user with a wrong password the
> method bind of the class LDAConnection does not raise any excpetion even if
> investigating in the “bindResp.getLdapResult().getDiagnosticMessage()”
> actually it returns the following string “Diagnostic message
> :INVALID_CREDENTIALS: Bind failed: ERR_229 Cannot authenticate user
> cn=Antonio Valentino,o=DEM.”
> Is it the correct behavior of the LDAPConnection bind method not returning
> any Exception?
Yes. It was a design decision. Exception are for exceptional conditions
(like a timeout, or any other error that we can't control).
When you have a success, or a failure, the BindResponse convey the
reason, and this is where you are going to have the best possible
explanation about the bind error.
Grab the ldapResult, and check the error code, which should be SUCCESS.
LdapResponse bindResponse = connection.bind( blah );
if ( bindResponse.getLdapResult().getResultCode() !=
ResultCodeEnum.SUCCESS )
{
// Deal with the error...
}
--
Emmanuel Lecharny
Symas.com
directory.apache.org