code: private String getConnectionSearchFilter(String userDN,
              LDAPConnection ldapConnection)
              throws LDAPException, GuacamoleException {
  
          // Create a search filter for the connection search
          StringBuilder connectionSearchFilter = new StringBuilder();
  
          // Add the prefix to the search filter, prefix filter searches for guacConfigGroups with the userDN as the member attribute value
          connectionSearchFilter.append("(&(objectClass=guacConfigGroup)");
          connectionSearchFilter.append("(|(");
          connectionSearchFilter.append(escapingService.escapeLDAPSearchFilter(
                  confService.getMemberAttribute()));
          connectionSearchFilter.append("=");
          connectionSearchFilter.append(escapingService.escapeLDAPSearchFilter(userDN));
          connectionSearchFilter.append(")");
  
          // Additionally filter by group membership if the current user is a
          // member of any user groups
          List<LDAPEntry> userGroups = userGroupService.getParentUserGroupEntries(ldapConnection, userDN);
          if (!userGroups.isEmpty()) {
              for (LDAPEntry entry : userGroups)
                  connectionSearchFilter.append("(seeAlso=").append(escapingService.escapeLDAPSearchFilter(entry.getDN())).append(")");
          }
  
          // Complete the search filter.
          connectionSearchFilter.append("))");
  
          return connectionSearchFilter.toString();
      }
  
  }
docs: Returns an LDAP search filter which queries all connections accessible
  by the user having the given DN.
  
  @param userDN
  DN of the user to search for associated guacConfigGroup connections.
  
  @param ldapConnection
  LDAP connection to use if additional information must be queried to
  produce the filter, such as groups driving RBAC.
  
  @return
  An LDAP search filter which queries all guacConfigGroup objects
  accessible by the user having the given DN.
  
  @throws LDAPException
  If an error occurs preventing retrieval of user groups.
  
  @throws GuacamoleException
  If an error occurs retrieving the group base DN.