public Query isUserMemberOfGroup(String userId, String groupDn) {
    Preconditions.checkState(!Strings.isNullOrEmpty(userMembershipAttr),
        MetastoreConf.METASTORE_AUTHENTICATION_LDAP_USERMEMBERSHIPKEY_NAME + " is not configured.");
    return Query.builder()
        .filter("(&(|<classes:{ class |(objectClass=<class>)}>)" +
            "(<userMembershipAttr>=<groupDn>)(<guidAttr>=<userId>))")
        .map("classes", USER_OBJECT_CLASSES)
        .map("guidAttr", guidAttr)
        .map("userMembershipAttr", userMembershipAttr)
        .map("userId", userId)
        .map("groupDn", groupDn)
        .limit(2)
        .build();
  }
Returns a query for checking whether specified user is a member of specified group.

The query requires {@value MetastoreConf#METASTORE_AUTHENTICATION_LDAP_USERMEMBERSHIPKEY_NAME}
Metastore configuration property to be set.

@param userId user unique identifier
@param groupDn group DN
@return an instance of {@link Query}
@see MetastoreConf.ConfVars#METASTORE_PLAIN_LDAP_USERMEMBERSHIP_KEY
@throws NullPointerException when
{@value MetastoreConf#METASTORE_AUTHENTICATION_LDAP_USERMEMBERSHIPKEY_NAME} is not set.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ldap/QueryFactory.java