src/main/java/reciter/connect/database/ldap/LDAPConnectionFactory.java
/**
	 * Searches the ED for the provided filter.
	 *
	 * @param filter        A valid LDAP filter string
	 * @param base          The LDAP search base you want to use
	 * @param propertyFilePath This is the file path of the property file which contains the connection info
	 * @param scope         A SearchScope that you want to use
	 * @param attributes    A list of attributes that you want returned from
	 * LDAP
	 * @return a {@code List} of {@code SearchResultEntry} objects.
	 */
Searches the ED for the provided filter.
Searches the ED for the provided filter .
public List<SearchResultEntry> search(final String filter, final String base, SearchScope scope, String... attributes) {
		LDAPConnection connection = null;
		List<SearchResultEntry> entries = new ArrayList<>();
		try {
			SearchRequest searchRequest = new SearchRequest(base, scope, filter, attributes);
			ASN1OctetString resumeCookie = null;
			int numSearches = 0;
			int totalEntriesReturned = 0;
			connection = getConnectionfromPool();
			if(connection != null) {
				while(true) {
					searchRequest.setControls(new SimplePagedResultsControl(500, resumeCookie));
					SearchResult results = connection.search(searchRequest);
					numSearches++;
   					totalEntriesReturned += results.getEntryCount();
					entries.addAll(results.getSearchEntries());
					SimplePagedResultsControl responseControl =SimplePagedResultsControl.get(results);
					if (responseControl.moreResultsToReturn())
					{
						resumeCookie = responseControl.getCookie();
					}
					else
					{
						break;
					}
				}
			}
		} catch (LDAPSearchException e) {
			slf4jLogger.error("LDAPSearchException", e);
		} catch (LDAPException e) {
			slf4jLogger.error("LDAPException", e);
		} finally {
			if (connection != null) {
				returnConnectionToPool(connection);
			}
		}
		return entries;
	}
public List < SearchResultEntry > search ( final String filter , final String base , SearchScope scope , String ... attributes ) { LDAPConnection connection = null ; List < SearchResultEntry > entries = new ArrayList < > ( ) ; try { SearchRequest searchRequest = new SearchRequest ( base , scope , filter , attributes ) ; ASN1OctetString resumeCookie = null ; int numSearches = 0 ; int totalEntriesReturned = 0 ; connection = getConnectionfromPool ( ) ; if ( connection != null ) { while ( true ) { searchRequest . setControls ( new SimplePagedResultsControl ( 500 , resumeCookie ) ) ; SearchResult results = connection . search ( searchRequest ) ; numSearches ++ ; totalEntriesReturned += results . getEntryCount ( ) ; entries . addAll ( results . getSearchEntries ( ) ) ; SimplePagedResultsControl responseControl = SimplePagedResultsControl . get ( results ) ; if ( responseControl . moreResultsToReturn ( ) ) { resumeCookie = responseControl . getCookie ( ) ; } else { break ; } } } } catch ( LDAPSearchException e ) { slf4jLogger . error ( "LDAPSearchException" , e ) ; } catch ( LDAPException e ) { slf4jLogger . error ( "LDAPException" , e ) ; } finally { if ( connection != null ) { returnConnectionToPool ( connection ) ; } } return entries ; }
Searches the ED for the provided filter.
Searches the ED for the provided filter .
// Perform a search to retrieve all users in the server, but only retrieving // ten at a time. //connection = LDAPConnectionFactory.getConnection(propertyFilePath); // The resume cookie can be included in the simple paged results // control included in the next search to get the next page of results.