{
ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
UrlAndDn urlAndDn = newReferralsInfo.getNext();
if ( urlAndDn != null )
{
LdapURL url = urlAndDn.getUrl();
Connection referralConnection = getReferralConnection( url, monitor, this );
if ( referralConnection != null )
{
String referralSearchBase = url.getDn() != null && !url.getDn().isEmpty() ? url
.getDn().getUpName() : searchBase;
String referralFilter = url.getFilter() != null && url.getFilter().length() == 0 ? url
.getFilter()
: filter;
SearchControls referralSearchControls = new SearchControls();
referralSearchControls.setSearchScope( url.getScope() > -1 ? url.getScope()
: searchControls.getSearchScope() );
referralSearchControls.setReturningAttributes( url.getAttributes() != null
&& url.getAttributes().size() > 0 ? url.getAttributes().toArray(
new String[url.getAttributes().size()] ) : searchControls
.getReturningAttributes() );
referralSearchControls.setCountLimit( searchControls.getCountLimit() );
referralSearchControls.setTimeLimit( searchControls.getTimeLimit() );
referralSearchControls.setDerefLinkFlag( searchControls.getDerefLinkFlag() );
referralSearchControls.setReturningObjFlag( searchControls.getReturningObjFlag() );