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