referral.addLdapUrl( ref );
continue;
}
// Parse the ref value
LdapUrl ldapUrl = null;
try
{
ldapUrl = new LdapUrl( ref );
}
catch ( LdapURLEncodingException e )
{
LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
}
// Normalize the Dn to check for same dn
Dn urlDn = new Dn( session.getCoreSession().getDirectoryService()
.getSchemaManager(), ldapUrl.getDn().getName() );
if ( urlDn.getNormName().equals( req.getBase().getNormName() ) )
{
ldapUrl.setForceScopeRendering( true );
ldapUrl.setAttributes( req.getAttributes() );
ldapUrl.setScope( req.getScope().getScope() );
referral.addLdapUrl( ldapUrl.toString() );
continue;
}
/*
* If we get here then the Dn of the referral was not the same as the
* Dn of the ref LDAP URL. We must calculate the remaining (difference)
* name past the farthest referral Dn which the target name extends.
*/
Dn suffix = req.getBase().getDescendantOf( referralAncestor.getDn() );
Dn refDn = urlDn.add( suffix );
ldapUrl.setDn( refDn );
ldapUrl.setForceScopeRendering( true );
ldapUrl.setAttributes( req.getAttributes() );
ldapUrl.setScope( req.getScope().getScope() );
referral.addLdapUrl( ldapUrl.toString() );
}
return referral;
}