/** * Get the descendant of a given DN, using the ancestr DN. Assuming that * a DN has two parts :<br> * DN = [descendant DN][ancestor DN]<br> * To get back the descendant from the full DN, you just pass the ancestor DN * as a parameter. Here is a working example : * <pre> * Dn dn = new Dn( "cn=test, dc=server, dc=directory, dc=apache, dc=org" ); * * Dn descendant = dn.getDescendantOf( "dc=apache, dc=org" ); * * // At this point, the descendant contains cn=test, dc=server, dc=directory" * </pre> * * @param ancestor The parent DN * @return The part of the DN that is the descendant * @throws LdapInvalidDnException If the Dn is invalid */ public Dn getDescendantOf( String ancestor ) throws LdapInvalidDnException { return getDescendantOf( new Dn( schemaManager, ancestor ) ); }
/** * Get the descendant of a given DN, using the ancestr DN. Assuming that * a DN has two parts :<br> * DN = [descendant DN][ancestor DN]<br> * To get back the descendant from the full DN, you just pass the ancestor DN * as a parameter. Here is a working example : * <pre> * Dn dn = new Dn( "cn=test, dc=server, dc=directory, dc=apache, dc=org" ); * * Dn descendant = dn.getDescendantOf( "dc=apache, dc=org" ); * * // At this point, the descendant contains cn=test, dc=server, dc=directory" * </pre> * * @param ancestor The parent DN * @return The part of the DN that is the descendant * @throws LdapInvalidDnException If the Dn is invalid */ public Dn getDescendantOf( String ancestor ) throws LdapInvalidDnException { return getDescendantOf( new Dn( schemaManager, ancestor ) ); }
/** * Get the descendant of a given DN, using the ancestr DN. Assuming that * a DN has two parts :<br> * DN = [descendant DN][ancestor DN]<br> * To get back the descendant from the full DN, you just pass the ancestor DN * as a parameter. Here is a working example : * <pre> * Dn dn = new Dn( "cn=test, dc=server, dc=directory, dc=apache, dc=org" ); * * Dn descendant = dn.getDescendantOf( "dc=apache, dc=org" ); * * // At this point, the descendant contains cn=test, dc=server, dc=directory" * </pre> * * @param ancestor The parent DN * @return The part of the DN that is the descendant * @throws LdapInvalidDnException If the Dn is invalid */ public Dn getDescendantOf( String ancestor ) throws LdapInvalidDnException { return getDescendantOf( new Dn( schemaManager, ancestor ) ); }
/** * Gets the prefix, cuts the suffix from the given Dn. * * @param dn the Dn * @param suffix the suffix * * @return the prefix */ public static Dn getPrefixName( Dn dn, Dn suffix ) { if ( suffix.size() < 1 ) { return null; } else { try { Dn prefix = dn.getDescendantOf( suffix ); return prefix; } catch ( LdapInvalidDnException lide ) { return null; } } }
public String rewriteBase(final String base) { try { Dn lowerCasedContextDn = (contextDn == null) ? null : new Dn(contextDn.toString().toLowerCase()); Dn lowerCasedBaseDn = new Dn(base.toLowerCase()); if (!lowerCasedBaseDn.isDescendantOf(lowerCasedContextDn)) { return base; } if (lowerCasedBaseDn.equals(lowerCasedContextDn)) { return ""; } Dn lowerCasedRelativeDn = lowerCasedBaseDn.getDescendantOf(lowerCasedContextDn); return base.substring(0, lowerCasedRelativeDn.toString().length()); } catch (LdapInvalidDnException e) { throw new RuntimeException(e); } }
filePath.append( suffixDirectory ).append( File.separator ); Dn baseDn = entryDn.getDescendantOf( suffixDn ); int size = baseDn.size();
Dn suffix = req.getBase().getDescendantOf( referralAncestor.getDn() ); urlDn = urlDn.add( suffix );
descendant = entryDn.getDescendantOf( nc ); namingContext = nc; break;
descendant = entryDn.getDescendantOf( nc ); namingContext = nc; break;
descendant = entryDn.getDescendantOf( nc ); namingContext = nc; break;
Dn entryRelativeDn = entryDn.getDescendantOf( apDn ).getDescendantOf( subtree.getBase() );
Dn suffix = req.getBase().getDescendantOf( referralAncestor.getDn() ); Dn refDn = urlDn.add( suffix );