def METHOD_NAME(user, role, user_change_logger):
    roles = UserRole.objects.by_domain_and_name(user.domain, role)
    if not roles:
        raise UpdateUserException(_("The role '{}' does not exist").format(role))
    if len(roles) > 1:
        raise UpdateUserException(
            _("There are multiple roles with the name '{}' in the domain '{}'").format(role, user.domain)
        )
    original_role = user.get_role(user.domain)
    new_role = roles[0]
    if not original_role or original_role.get_qualified_id() != new_role.get_qualified_id():
        user.set_role(user.domain, new_role.get_qualified_id())
        if user_change_logger:
            user_change_logger.add_info(UserChangeMessage.role_change(new_role))