code: public List<String> getGroups(final DirContext dirContext, final LdapUser ldapUser) throws NamingException {
          LOGGER.debug("Retrieving groups for: " + ldapUser.getDN());
          final List<String> groupDns = new ArrayList<>();
          final String searchFilter = variableSubstitution(USER_GROUPS_FILTER, ldapUser);
          final SearchControls sc = new SearchControls();
          sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
          final NamingEnumeration<SearchResult> ne = dirContext.search(BASE_DN, searchFilter, sc);
          while (hasMoreEnum(ne)) {
              final SearchResult result = ne.next();
              groupDns.add(result.getNameInNamespace());
              LOGGER.debug("Found group: " + result.getNameInNamespace() + " for user: " + ldapUser.getDN());
          }
          closeQuietly(ne);
          return groupDns;
      }
docs: Retrieves a list of all groups the user is a member of.
  @param dirContext a DirContext
  @param ldapUser the LdapUser to retrieve group membership for
  @return A list of Strings representing the fully qualified DN of each group
  @throws NamingException if an exception is thrown
  @since 1.4.0