public final void dump ( final LDAPInterface connection , final String base , final String filter , final OutputStream outputStream , final FormatLogger logger ) { final FormatWriter ldapWriter = createWriter ( outputStream , logger ) ; if ( ldapWriter == null ) { logger . logError ( "Error creating writer for output stream" ) ; } else { try { try { final SearchRequest request = new SearchRequest ( base , SearchScope . SUB , Filter . create ( filter ) ) ; final SearchResult result = connection . search ( request ) ; if ( result . getResultCode ( ) == ResultCode . SUCCESS ) { final List < SearchResultEntry > entries = result . getSearchEntries ( ) ; if ( entries != null ) { for ( final SearchResultEntry entry : entries ) { ldapWriter . printEntry ( entry ) ; } } else { logger . logInfo ( "Search did not return any directory entries" ) ; } } else { logger . logError ( "Search operation failed" ) ; } } catch ( final LDAPException e ) { logger . logError ( "Error searching the LDAP directory" , e ) ; } finally { ldapWriter . close ( ) ; } } catch ( final IOException e ) { logger . logError ( "Error writing directory entry to the output stream" , e ) ; } } }
Dump the results of a search against the LDAP directory server to an output stream .