setProcessingStartTime();
// Log the bind request message.
logBindRequest(this);
ClientConnection clientConnection = getClientConnection();
// Wipe out any existing authentication for the client connection and create
// a placeholder that will be used if the bind is successful.
clientConnection.setUnauthenticated();
// Abandon any operations that may be in progress for the client.
Message cancelReason = INFO_CANCELED_BY_BIND_REQUEST.get();
CancelRequest cancelRequest = new CancelRequest(true, cancelReason);
clientConnection.cancelAllOperationsExcept(cancelRequest, getMessageID());
// Get the plugin config manager that will be used for invoking plugins.
PluginConfigManager pluginConfigManager =
DirectoryServer.getPluginConfigManager();
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
try
{
// Invoke the pre-parse bind plugins.
PluginResult.PreParse preParseResult =
pluginConfigManager.invokePreParseBindPlugins(this);
if (!preParseResult.continueProcessing())
{
setResultCode(preParseResult.getResultCode());
appendErrorMessage(preParseResult.getErrorMessage());
setMatchedDN(preParseResult.getMatchedDN());
setReferralURLs(preParseResult.getReferralURLs());
return;
}
// Process the bind DN to convert it from the raw form as provided by the
// client into the form required for the rest of the bind processing.
DN bindDN = getBindDN();
if (bindDN == null){
return;
}
// If this is a simple bind
// Then check wether the bind DN is actually one of the alternate root DNs
// defined in the server. If so, then replace it with the actual DN
// for that user.
switch (getAuthenticationType())
{
case SIMPLE:
DN actualRootDN = DirectoryServer.getActualRootBindDN(bindDN);
if (actualRootDN != null)
{
bindDN = actualRootDN;
}
}
// Special case to manage RootDNs
// RootDNs are stored in cn=config but this workflow is not
// available through non-admin network groups.
// So if the bind DN is in cn=config, we directly retrieve
// the workflow handling cn=config
// FIXME: it would be better to store RootDNs in a separate backend.
// Issue #3502 has been logged to track this request.
boolean isInConfig;
try {
isInConfig = bindDN.isDescendantOf(DN.decode(DN_CONFIG_ROOT));
} catch (DirectoryException ex) {
// can not happen
isInConfig = false;
}
Workflow workflow;
if (isInConfig) {
workflow = WorkflowImpl.getWorkflow("__config.ldif__#cn=config");
} else {
// Retrieve the network group attached to the client connection
// and get a workflow to process the operation.
NetworkGroup ng = getClientConnection().getNetworkGroup();
workflow = ng.getWorkflowCandidate(bindDN);
}
if (workflow == null)
{
// We have found no workflow for the requested base DN, just return
// a no such entry result code and stop the processing.
updateOperationErrMsgAndResCode();
return;
}
workflow.execute(this);
workflowExecuted = true;
}
catch(CanceledOperationException coe)
{
// This shouldn't happen for bind operations. Just cancel anyways
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, coe);
}
setResultCode(ResultCode.CANCELED);
appendErrorMessage(cancelRequest.getCancelReason());
}
finally
{
// Stop the processing timer.
setProcessingStopTime();
// Log the bind response.
logBindResponse(this);
// Send the bind response to the client.
clientConnection.sendResponse(this);
// If the bind processing is finished, then unset the "bind in progress"
// flag to allow other operations to be processed on the connection.
if (getResultCode() != ResultCode.SASL_BIND_IN_PROGRESS)
{
clientConnection.finishSaslBind();
}
clientConnection.finishBindOrStartTLS();
// Invoke the post-response bind plugins.
invokePostResponsePlugins(workflowExecuted);
}
}