/** * Gets the full dn of a name by prepending the name of the context it is relative to. * If the name already contains the base name, it is returned unaltered. */ public static DistinguishedName getFullDn(DistinguishedName dn, Context baseCtx) throws NamingException { DistinguishedName baseDn = new DistinguishedName(baseCtx.getNameInNamespace()); if (dn.contains(baseDn)) { return dn; } baseDn.append(dn); return baseDn; }
/** * Gets the full dn of a name by prepending the name of the context it is relative to. * If the name already contains the base name, it is returned unaltered. */ public static DistinguishedName getFullDn(DistinguishedName dn, Context baseCtx) throws NamingException { DistinguishedName baseDn = new DistinguishedName(baseCtx.getNameInNamespace()); if (dn.contains(baseDn)) { return dn; } baseDn.append(dn); return baseDn; }
/** * Gets the full dn of a name by prepending the name of the context it is relative to. * If the name already contains the base name, it is returned unaltered. */ public static DistinguishedName getFullDn(DistinguishedName dn, Context baseCtx) throws NamingException { DistinguishedName baseDn = new DistinguishedName(baseCtx.getNameInNamespace()); if(dn.contains(baseDn)) { return dn; } baseDn.append(dn); return baseDn; }
/** * Tests parsing and toString. */ @Test public void testContains() { DistinguishedName migpath = new DistinguishedName("OU=G,OU=I,OU=M"); DistinguishedName path1 = new DistinguishedName("cn=john.doe, OU=Users,OU=SE,OU=G,OU=I,OU=M"); DistinguishedName path2 = new DistinguishedName("cn=john.doe, OU=Users,OU=SE,ou=G,OU=i,OU=M, ou=foo"); DistinguishedName path3 = new DistinguishedName("ou=G,OU=i,OU=M, ou=foo"); DistinguishedName path4 = new DistinguishedName("ou=G,OU=i,ou=m"); DistinguishedName pathE1 = new DistinguishedName("cn=john.doe, OU=Users,OU=SE,ou=G,OU=L,OU=M, ou=foo"); DistinguishedName pathE2 = new DistinguishedName("cn=john.doe, OU=Users,OU=SE"); assertThat(path1.contains(migpath)).isTrue(); assertThat(path2.contains(migpath)).isTrue(); assertThat(path3.contains(migpath)).isTrue(); assertThat(path4.contains(migpath)).isTrue(); assertThat(pathE1.contains(migpath)).isFalse(); assertThat(pathE2.contains(migpath)).isFalse(); }