UN diplomats have walked out of a speech in protest at comments delivered by Iranian President Mahmoud Ahmadinejad.