public List<String> getAllLdapNamesAndAttributes() throws NamingException {
    final List<String> result = new ArrayList<>();
    handle(new RecordProcessor() {
      @Override
      public boolean process(SearchResult record) throws NamingException {
        result.add(record.getNameInNamespace());
        NamingEnumeration<? extends Attribute> allAttributes = record.getAttributes().getAll();
        while(allAttributes.hasMore()) {
          Attribute attribute = allAttributes.next();
          addAllAttributeValuesToResult(attribute.getAll());
        }
        return true;
      }

      private void addAllAttributeValuesToResult(NamingEnumeration values) throws NamingException {
        while(values.hasMore()) {
          result.add(String.valueOf(values.next()));
        }
      }

    });
    return result;
  }
Returns all entries and all attributes for these entries.
@return a list that includes all entries and all attributes from these entries.
@throws NamingException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ldap/SearchResultHandler.java