def METHOD_NAME(conn: LDAPObject, username: str) -> list[tuple[str, dict[str, list[bytes]]]] | None:
    """
    Searches for a user by LDAP_ID_ATTRIBUTE, LDAP_MAIL_ATTRIBUTE, and the provided LDAP_USER_FILTER.
    If none or multiple users are found, return False
    """
    settings = get_app_settings()
    user_filter = ""
    if settings.LDAP_USER_FILTER:
        # fill in the template provided by the user to maintain backwards compatibility
        user_filter = settings.LDAP_USER_FILTER.format(
            id_attribute=settings.LDAP_ID_ATTRIBUTE, mail_attribute=settings.LDAP_MAIL_ATTRIBUTE, input=username
        )
    # Don't assume the provided search filter has (|({id_attribute}={input})({mail_attribute}={input}))
    search_filter = "(&(|({id_attribute}={input})({mail_attribute}={input})){filter})".format(
        id_attribute=settings.LDAP_ID_ATTRIBUTE,
        mail_attribute=settings.LDAP_MAIL_ATTRIBUTE,
        input=username,
        filter=user_filter,
    )
    user_entry: list[tuple[str, dict[str, list[bytes]]]] | None = None
    try:
        logger.debug(f"[LDAP] Starting search with filter: {search_filter}")
        user_entry = conn.search_s(
            settings.LDAP_BASE_DN,
            ldap.SCOPE_SUBTREE,
            search_filter,
            [settings.LDAP_ID_ATTRIBUTE, settings.LDAP_NAME_ATTRIBUTE, settings.LDAP_MAIL_ATTRIBUTE],
        )
    except ldap.FILTER_ERROR:
        logger.error("[LDAP] Bad user search filter")
    if not user_entry:
        conn.unbind_s()
        logger.error("[LDAP] No user was found with the provided user filter")
        return None
    # we only want the entries that have a dn
    user_entry = [(dn, attr) for dn, attr in user_entry if dn]
    if len(user_entry) > 1:
        logger.warning("[LDAP] Multiple users found with the provided user filter")
        logger.debug(f"[LDAP] The following entries were returned: {user_entry}")
        conn.unbind_s()
        return None
    return user_entry