*/
private BindRequest createBindRequest( String name, byte[] credentials, String saslMechanism, Control... controls )
throws LdapException
{
// Set the new messageId
BindRequest bindRequest = new BindRequestImpl();
// Set the version
bindRequest.setVersion3( true );
// Set the name
bindRequest.setName( name );
// Set the credentials
if ( Strings.isEmpty( saslMechanism ) )
{
// Simple bind
bindRequest.setSimple( true );
bindRequest.setCredentials( credentials );
}
else
{
// SASL bind
bindRequest.setSimple( false );
bindRequest.setCredentials( credentials );
bindRequest.setSaslMechanism( saslMechanism );
}
// Add the controls
if ( ( controls != null ) && ( controls.length != 0 ) )
{
bindRequest.addAllControls( controls );
}
return bindRequest;
}