use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class ModifyRequest method processSync.
/**
* Processes this modify operation in synchronous mode, in which the same
* thread will send the request and read the response.
*
* @param connection The connection to use to communicate with the directory
* server.
* @param depth The current referral depth for this request. It should
* always be one for the initial request, and should only
* be incremented when following referrals.
* @param allowRetry Indicates whether the request may be re-tried on a
* re-established connection if the initial attempt fails
* in a way that indicates the connection is no longer
* valid and autoReconnect is true.
*
* @return An LDAP result object that provides information about the result
* of the modify processing.
*
* @throws LDAPException If a problem occurs while sending the request or
* reading the response.
*/
@NotNull()
private LDAPResult processSync(@NotNull final LDAPConnection connection, final int depth, final boolean allowRetry) throws LDAPException {
// Create the LDAP message.
messageID = connection.nextMessageID();
final LDAPMessage message = new LDAPMessage(messageID, this, getControls());
// Send the request to the server.
final long requestTime = System.nanoTime();
Debug.debugLDAPRequest(Level.INFO, this, messageID, connection);
final LDAPConnectionLogger logger = connection.getConnectionOptions().getConnectionLogger();
if (logger != null) {
logger.logModifyRequest(connection, messageID, this);
}
connection.getConnectionStatistics().incrementNumModifyRequests();
try {
connection.sendMessage(message, getResponseTimeoutMillis(connection));
} catch (final LDAPException le) {
Debug.debugException(le);
if (allowRetry) {
final LDAPResult retryResult = reconnectAndRetry(connection, depth, le.getResultCode());
if (retryResult != null) {
return retryResult;
}
}
throw le;
}
while (true) {
final LDAPResponse response;
try {
response = connection.readResponse(messageID);
} catch (final LDAPException le) {
Debug.debugException(le);
if ((le.getResultCode() == ResultCode.TIMEOUT) && connection.getConnectionOptions().abandonOnTimeout()) {
connection.abandon(messageID);
}
if (allowRetry) {
final LDAPResult retryResult = reconnectAndRetry(connection, depth, le.getResultCode());
if (retryResult != null) {
return retryResult;
}
}
throw le;
}
if (response instanceof IntermediateResponse) {
final IntermediateResponseListener listener = getIntermediateResponseListener();
if (listener != null) {
listener.intermediateResponseReturned((IntermediateResponse) response);
}
} else {
return handleResponse(connection, response, requestTime, depth, allowRetry);
}
}
}
use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class SASLBindRequest method sendBindRequest.
/**
* Sends an LDAP message to the directory server and waits for the response.
*
* @param connection The connection to the directory server.
* @param bindDN The bind DN to use for the request. It should be
* {@code null} for most types of SASL bind requests.
* @param saslCredentials The SASL credentials to use for the bind request.
* It may be {@code null} if no credentials are
* required.
* @param controls The set of controls to include in the request. It
* may be {@code null} if no controls are required.
* @param timeoutMillis The maximum length of time in milliseconds to wait
* for a response, or zero if it should wait forever.
*
* @return The bind response message returned by the directory server.
*
* @throws LDAPException If a problem occurs while sending the request or
* reading the response, or if a timeout occurred
* while waiting for the response.
*/
@NotNull()
protected final BindResult sendBindRequest(@NotNull final LDAPConnection connection, @Nullable final String bindDN, @Nullable final ASN1OctetString saslCredentials, @Nullable final Control[] controls, final long timeoutMillis) throws LDAPException {
messageID = connection.nextMessageID();
final BindRequestProtocolOp protocolOp = new BindRequestProtocolOp(bindDN, getSASLMechanismName(), saslCredentials);
final LDAPMessage requestMessage = new LDAPMessage(messageID, protocolOp, controls);
return sendMessage(connection, requestMessage, timeoutMillis);
}
Aggregations