The president made a surprise visit to Bagram Air Field, where he mingled with the military in the canteen.