BindResponse bindResponse = null;
// No Authentication
if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.NONE )
{
BindRequest bindRequest = new BindRequestImpl();
bindResponse = ldapConnection.bind( bindRequest );
}
else
{
// Setup credentials
IAuthHandler authHandler = ConnectionCorePlugin.getDefault().getAuthHandler();
if ( authHandler == null )
{
Exception exception = new Exception( Messages.model__no_auth_handler );
monitor.setCanceled( true );
monitor.reportError( Messages.model__no_auth_handler, exception );
throw exception;
}
ICredentials credentials = authHandler.getCredentials( connection.getConnectionParameter() );
if ( credentials == null )
{
Exception exception = new Exception();
monitor.setCanceled( true );
monitor.reportError( Messages.model__no_credentials, exception );
throw exception;
}
if ( credentials.getBindPrincipal() == null || credentials.getBindPassword() == null )
{
Exception exception = new Exception( Messages.model__no_credentials );
monitor.reportError( Messages.model__no_credentials, exception );
throw exception;
}
bindPrincipal = credentials.getBindPrincipal();
bindPassword = credentials.getBindPassword();
// Simple Authentication
if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SIMPLE )
{
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setName( bindPrincipal );
bindRequest.setCredentials( bindPassword );
bindResponse = ldapConnection.bind( bindRequest );
}
// CRAM-MD5 Authentication
else if ( connection.getConnectionParameter().getAuthMethod() == ConnectionParameter.AuthenticationMethod.SASL_CRAM_MD5 )
{