public Cursor<Entry> search( SearchRequest searchRequest ) throws LdapException
{
SearchOperationContext searchContext = new SearchOperationContext( this, searchRequest );
searchContext.setSyncreplSearch( searchRequest.getControls().containsKey( SyncRequestValue.OID ) );
OperationManager operationManager = directoryService.getOperationManager();
// Check if we received serverside sort Control
SortRequest sortControl = ( SortRequest ) searchRequest.getControls().get( SortRequest.OID );
SortResponse sortRespCtrl = null;
ResultResponse done = searchRequest.getResultResponse();
LdapResult ldapResult = done.getLdapResult();
if ( sortControl != null )
{
sortRespCtrl = canSort( sortControl, ldapResult, getDirectoryService().getSchemaManager() );
if ( sortControl.isCritical() && ( sortRespCtrl.getSortResult() != SortResultCode.SUCCESS ) )
{
ldapResult.setResultCode( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
done.addControl( sortRespCtrl );
return new EmptyCursor<Entry>();
}
}
Cursor<Entry> cursor = null;
try
{
cursor = operationManager.search( searchContext );
if ( ( sortRespCtrl != null ) && ( sortRespCtrl.getSortResult() == SortResultCode.SUCCESS ) )
{
cursor = sortResults( cursor, sortControl, getDirectoryService().getSchemaManager() );
}