Iran's supreme leader ordered a shake-up of the intelligence system after recent incidents exposed gaps in the security apparatus.