public Query findGroupsForUser(String userName, String userDn) {
    return Query.builder()
        .filter("(&(objectClass=<groupClassAttr>)(|(<groupMembershipAttr>=<userDn>)"
            + "(<groupMembershipAttr>=<userName>)))")
        .map("groupClassAttr", groupClassAttr)
        .map("groupMembershipAttr", groupMembershipAttr)
        .map("userName", userName)
        .map("userDn", userDn)
        .build();
  }
Returns a query for finding groups to which the user belongs.
@param userName username
@param userDn user DN
@return an instance of {@link Query}
service/src/java/org/apache/hive/service/auth/ldap/QueryFactory.java