code: 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;
          }
      }
docs: Construct a new LdapName instance from the supplied Name instance.
  LdapName instances will be cloned, CompositeName tweaks will be managed using
  {@link #convertCompositeNameToString(javax.naming.CompositeName)}; for all other Name
  implementations, new LdapName instances are constructed using {@link LdapName#addAll(int, javax.naming.Name)}.
  
  @param name the Name instance to convert to LdapName, not <code>null</code>.
  @return a new LdapName representing the same Distinguished Name as the supplied instance.
  @throws org.springframework.ldap.InvalidNameException to wrap any InvalidNameExceptions thrown by LdapName.
  @since 2.0