code: @Override
      public Set<Node> getGroupsForUser(Node user) {
          Set<Node> groups = new TreeSet<>();
          try {
              String query = "(& (objectClass=" + groupObjectClass + ") (" + groupMemberAttribut + "=" + ((LdapUser) user).getDn() + "))";
              SearchResult searchResult;
              Attributes attributes;
              SearchControls controls = new SearchControls();
              controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
              NamingEnumeration<SearchResult> results = ctx.search("", query, controls);
              queryCount++;
              Node group;
              while (results.hasMore()) {
                  searchResult = results.next();
                  attributes = searchResult.getAttributes();
                  group = getGroup(getAttributeOrNa(attributes, groupIdentifyer));
                  group.setDn(searchResult.getNameInNamespace());
                  groups.add(group);
              }
          } catch (NamingException ex) {
              handleNamingException(user, ex);
          }
          return groups;
      }
docs: Load all Groups for a given User.
  
  @param user the given User.
  @return Groups as a Set of Nodes for that User.