in src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java [487:567]
List<Bind> searchBinds( UserAudit audit ) throws FinderException
{
List<Bind> auditList = new ArrayList<>();
LdapConnection ld = null;
String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );
try
{
String filter;
if ( audit.getUserId() != null && audit.getUserId().length() > 0 )
{
filter = GlobalIds.FILTER_PREFIX + ACCESS_BIND_CLASS_NM + ")(" +
REQDN + "=" + SchemaConstants.UID_AT + "=" + audit.getUserId() + "," + userRoot + ")";
if ( audit.isFailedOnly() )
{
filter += "(" + REQRESULT + ">=" + 1 + ")";
}
if ( audit.getBeginDate() != null )
{
String szTime = TUtil.encodeGeneralizedTime( audit.getBeginDate() );
filter += "(" + REQEND + ">=" + szTime + ")";
}
filter += ")";
}
else
{
filter = GlobalIds.FILTER_PREFIX + ACCESS_BIND_CLASS_NM + ")";
if ( audit.isFailedOnly() )
{
filter += "(" + REQRESULT + ">=" + 1 + ")";
}
if ( audit.getBeginDate() != null )
{
String szTime = TUtil.encodeGeneralizedTime( audit.getBeginDate() );
filter += "(" + REQEND + ">=" + szTime + ")";
}
filter += ")";
}
//log.warn("filter=" + filter);
ld = getLogConnection();
try ( SearchCursor searchResults = search( ld, auditRoot,
SearchScope.ONELEVEL, filter, AUDIT_BIND_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
{
long sequence = 0;
while ( searchResults.next() )
{
auditList.add( getBindEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
}
}
catch ( IOException i )
{
String error = "IOException in AuditDAO.searchBinds id=" + i.getMessage();
throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, i );
}
catch ( CursorException e )
{
String error = "CursorException in AuditDAO.searchBinds id=" + e.getMessage();
throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e );
}
}
catch ( LdapException e )
{
String error = "LdapException in AuditDAO.searchBinds id=" + e;
throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e );
}
finally
{
closeLogConnection( ld );
}
return auditList;
}