ldap/src/main/java/org/springframework/security/ldap/LdapUtils.java
public static String getRelativeName(String fullDn, Context baseCtx)
			throws NamingException {

		String baseDn = baseCtx.getNameInNamespace();

		if (baseDn.length() == 0) {
			return fullDn;
		}

		DistinguishedName base = new DistinguishedName(baseDn);
		DistinguishedName full = new DistinguishedName(fullDn);

		if (base.equals(full)) {
			return "";
		}

		Assert.isTrue(full.startsWith(base), "Full DN does not start with base DN");

		full.removeFirst(base);

		return full.toString();
	}
public static String getRelativeName(String fullDn, Context baseCtx)
			throws NamingException {

		String baseDn = baseCtx.getNameInNamespace();

		if (baseDn.length() == 0) {
			return fullDn;
		}

		DistinguishedName base = new DistinguishedName(baseDn);
		DistinguishedName full = new DistinguishedName(fullDn);

		if (base.equals(full)) {
			return "";
		}

		Assert.isTrue(full.startsWith(base), "Full DN does not start with base DN");

		full.removeFirst(base);

		return full.toString();
	}
Obtains the part of a DN relative to a supplied base context.
<p>
If the DN is "cn=bob,ou=people,dc=springframework,dc=org" and the base context name
is "ou=people,dc=springframework,dc=org" it would return "cn=bob".
</p>

@param fullDn the DN
@param baseCtx the context to work out the name relative to.

@return the

@throws NamingException any exceptions thrown by the context are propagated.