public Query findUserDnByName(String userName) {
    return Query.builder()
        .filter("(&(|<classes:{ class |(objectClass=<class>)}>)"
            + "(|(uid=<userName>)(sAMAccountName=<userName>)))")
        .map("classes", USER_OBJECT_CLASSES)
        .map("userName", userName)
        .limit(2)
        .build();
  }
Returns a query for finding user DN based on user unique name.
@param userName user unique name (uid or sAMAccountName)
@return an instance of {@link Query}
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ldap/QueryFactory.java