public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
// create a new Bind context, with a null session, as we don't have
// any context yet.
BindOperationContext bindContext = new BindOperationContext( null );
// Stores the Dn of the user to check, and its password
bindContext.setDn( bindRequest.getDn() );
bindContext.setCredentials( bindRequest.getCredentials() );
bindContext.setInterceptors( ldapSession.getLdapServer().getDirectoryService()
.getInterceptors( OperationEnum.BIND ) );
// Stores the request controls into the operation context
LdapProtocolUtils.setRequestControls( bindContext, bindRequest );
try
{
CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
// And call the OperationManager bind operation.
adminSession.getDirectoryService().getOperationManager().bind( bindContext );
// As a result, store the created session in the Core Session
ldapSession.setCoreSession( bindContext.getSession() );
// Return the successful response
BindResponse response = ( BindResponse ) bindRequest.getResultResponse();
response.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
LdapProtocolUtils.setResponseControls( bindContext, response );