def get_duplicate_users(domain):
    by_username = defaultdict(list)
    for user_id, username in get_all_user_id_username_pairs_by_domain(domain, include_web_users=False):
        by_username[username].append(user_id)

    dupes = {}
    for username, user_ids in by_username.items():
        if len(user_ids) > 1:
            dupes[username] = user_ids
    return dupes