public List<Dn> getUserDNs(LDAPConfiguration config, LdapNetworkConnection ldapConnection,
            String username) throws GuacamoleException {

        // Retrieve user objects having a matching username
        List<Entry> results = queryService.search(config, ldapConnection,
                config.getUserBaseDN(),
                config.getUserSearchFilter(),
                config.getUsernameAttributes(),
                username,
                Collections.singletonList("dn"));

        // Build list of all DNs for retrieved users
        List<Dn> userDNs = new ArrayList<>(results.size());
        results.forEach(entry -> userDNs.add(entry.getDn()));

        return userDNs;

    }
Returns a list of all DNs corresponding to the users having the given
username. If multiple username attributes are defined, or if uniqueness
is not enforced across the username attribute, it is possible that this
will return multiple DNs.

@param config
    The configuration of the LDAP server being queried.

@param ldapConnection
    The connection to the LDAP server to use when querying user DNs.

@param username
    The username of the user whose corresponding user account DNs are
    to be retrieved.

@return
    A list of all DNs corresponding to the users having the given
    username. If no such DNs exist, this list will be empty.

@throws GuacamoleException
    If an error occurs while querying the user DNs, or if the username
    attribute property cannot be parsed within guacamole.properties.
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java