LdapUtils { public static LdapName newLdapName(Name name) { Assert.notNull(name, "name must not be null"); if(name instanceof LdapName) { return (LdapName) name.clone(); } else if (name instanceof CompositeName) { CompositeName compositeName = (CompositeName) name; try { return new LdapName(convertCompositeNameToString(compositeName)); } catch (InvalidNameException e) { throw convertLdapException(e); } } else { LdapName result = emptyLdapName(); try { result.addAll(0, name); } catch (InvalidNameException e) { throw convertLdapException(e); } return result; } } private  LdapUtils(); static void closeContext(DirContext context); static NamingException convertLdapException(javax.naming.NamingException ex); static Class getActualTargetClass(DirContext context); static void collectAttributeValues(Attributes attributes, String name, Collection<Object> collection); static void collectAttributeValues(
            Attributes attributes, String name, Collection<T> collection, Class<T> clazz); static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler); static String convertCompositeNameToString(
			CompositeName compositeName); static LdapName newLdapName(Name name); static LdapName newLdapName(String distinguishedName); static LdapName removeFirst(Name dn, Name pathToRemove); static LdapName prepend(Name dn, Name pathToPrepend); static LdapName emptyLdapName(); static Rdn getRdn(Name name, String key); static Object getValue(Name name, String key); static Object getValue(Name name, int index); static String getStringValue(Name name, int index); static String getStringValue(Name name, String key); static String convertBinarySidToString(byte[] sid); static byte[] convertStringSidToBinary(String string);  }
@Test public void testNewLdapNameFromLdapName() throws InvalidNameException { LdapName ldapName = new LdapName(EXPECTED_DN_STRING); LdapName result = LdapUtils.newLdapName(ldapName); assertThat(result).isEqualTo(ldapName); }
@Test public void testNewLdapNameFromCompositeName() throws InvalidNameException { LdapName result = LdapUtils.newLdapName(new CompositeName(EXPECTED_DN_STRING)); assertThat(result).isEqualTo(new LdapName(EXPECTED_DN_STRING)); }