public static List<String> createCandidatePrincipals(Configuration conf, String user) {
    if (hasDomain(user) || isDn(user)) {
      return Collections.singletonList(user);
    }

    String ldapDomain = MetastoreConf.getVar(conf,
            MetastoreConf.ConfVars.METASTORE_PLAIN_LDAP_DOMAIN);
    if (StringUtils.isNotBlank(ldapDomain)) {
      return Collections.singletonList(user + "@" + ldapDomain);
    }

    List<String> userPatterns = parseDnPatterns(conf,
        MetastoreConf.ConfVars.METASTORE_PLAIN_LDAP_USERDNPATTERN);
    if (userPatterns.isEmpty()) {
      return Collections.singletonList(user);
    }

    List<String> candidatePrincipals = new ArrayList<>();
    for (String userPattern : userPatterns) {
      candidatePrincipals.add(userPattern.replaceAll("%s", user));
    }
    return candidatePrincipals;
  }
Creates a list of principals to be used for user authentication.
@param conf Hive configuration
@param user username
@return a list of user's principals
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ldap/LdapUtils.java