use of org.apache.directory.api.ldap.model.message.BindRequest in project directory-ldap-api by apache.
the class LdapNetworkConnection method bind.
/**
* {@inheritDoc}
*/
@Override
public void bind() throws LdapException {
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03213_BIND));
}
// Create the BindRequest
BindRequest bindRequest = createBindRequest(config.getName(), Strings.getBytesUtf8(config.getCredentials()));
BindResponse bindResponse = bind(bindRequest);
processResponse(bindResponse);
}
use of org.apache.directory.api.ldap.model.message.BindRequest in project directory-ldap-api by apache.
the class LdapNetworkConnection method anonymousBind.
/**
* {@inheritDoc}
*/
@Override
public void anonymousBind() throws LdapException {
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03210_ANONYMOUS_BIND));
}
// Create the BindRequest
BindRequest bindRequest = createBindRequest(StringConstants.EMPTY, Strings.EMPTY_BYTES);
BindResponse bindResponse = bind(bindRequest);
processResponse(bindResponse);
}
use of org.apache.directory.api.ldap.model.message.BindRequest in project directory-ldap-api by apache.
the class AbstractLdapConnection method bind.
/**
* {@inheritDoc}
*/
@Override
public void bind(Dn name, String credentials) throws LdapException {
byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8(credentials);
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn(name);
bindRequest.setCredentials(credBytes);
BindResponse bindResponse = bind(bindRequest);
processResponse(bindResponse);
}
use of org.apache.directory.api.ldap.model.message.BindRequest in project directory-ldap-api by apache.
the class AbstractLdapConnection method createBindRequest.
/**
* Create a complete BindRequest ready to be sent.
*
* @param name The DN to bind with
* @param credentials The user's password
* @param saslMechanism The SASL mechanism to use
* @param controls The controls to send
* @return The created BindRequest
*/
protected BindRequest createBindRequest(String name, byte[] credentials, String saslMechanism, Control... controls) {
// 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;
}
use of org.apache.directory.api.ldap.model.message.BindRequest in project directory-ldap-api by apache.
the class AbstractLdapConnection method bind.
/**
* {@inheritDoc}
*/
@Override
public void bind(Dn name) throws LdapException {
byte[] credBytes = Strings.EMPTY_BYTES;
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn(name);
bindRequest.setCredentials(credBytes);
BindResponse bindResponse = bind(bindRequest);
processResponse(bindResponse);
}
Aggregations