code: public Map<String, UserGroup> getUserGroups(LDAPConnection ldapConnection)
              throws GuacamoleException {
  
          // Do not return any user groups if base DN is not specified
          String groupBaseDN = confService.getGroupBaseDN();
          if (groupBaseDN == null)
              return Collections.emptyMap();
  
          // Retrieve all visible user groups which are not guacConfigGroups
          Collection<String> attributes = confService.getGroupNameAttributes();
          List<LDAPEntry> results = queryService.search(
              ldapConnection,
              groupBaseDN,
              getGroupSearchFilter(),
              attributes,
              null
          );
  
          // Convert retrieved user groups to map of identifier to Guacamole
          // user group object
          return queryService.asMap(results, entry -> {
  
              // Translate entry into UserGroup object having proper identifier
              String name = queryService.getIdentifier(entry, attributes);
              if (name != null)
                  return new SimpleUserGroup(name);
  
              // Ignore user groups which lack a name attribute
              logger.debug("User group \"{}\" is missing a name attribute "
                      + "and will be ignored.", entry.getDN());
              return null;
  
          });
  
      }
docs: Returns all Guacamole user groups accessible to the user currently bound
  under the given LDAP connection.
  
  @param ldapConnection
  The current connection to the LDAP server, associated with the
  current user.
  
  @return
  All user groups accessible to the user currently bound under the
  given LDAP connection, as a map of user group identifier to
  corresponding UserGroup object.
  
  @throws GuacamoleException
  If an error occurs preventing retrieval of user groups.