code: public static Rdn getRdn(Name name, String key) {
          Assert.notNull(name, "name must not be null");
          Assert.hasText(key, "key must not be blank");
  
          LdapName ldapName = returnOrConstructLdapNameFromName(name);
  
          List<Rdn> rdns = ldapName.getRdns();
          for (Rdn rdn : rdns) {
              NamingEnumeration<String> ids = rdn.toAttributes().getIDs();
              while (ids.hasMoreElements()) {
                  String id = ids.nextElement();
                  if(key.equalsIgnoreCase(id)) {
                      return rdn;
                  }
              }
          }
  
          throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'");
      }
docs: Find the Rdn with the requested key in the supplied Name.
  
  @param name the Name in which to search for the key.
  @param key the attribute key to search for.
  @return the rdn corresponding to the <b>first</b> occurrence of the requested key.
  @throws NoSuchElementException if no corresponding entry is found.
  @since 2.0