@Test
public void testSearchWithDerefAlias() throws Exception
{
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBaseDn( "ou=users,ou=system" );
searchRequest.setFilter( "(objectClass=*)" );
searchRequest.setScope( SearchScope.ONELEVEL );
searchRequest.addAttributes( "*" );
int count = 0;
Cursor<SearchResponse> cursor = connection.search( searchRequest );
while( cursor.next() )
{
count++;
}
// due to dereferencing of aliases we get only one entry
assertEquals( 1, count );
count = 0;
searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
cursor = connection.search( searchRequest );
while( cursor.next() )
{
count++;
}