The Senate has advanced legislation that seeks to force President Donald Trump to withdraw from the Iran war.