The difficult thing in dealing with Iran is the complex, divided, and often opaque nature of the decision-making process, especially on national security issues. During the Khatemi period it wasn't unusual to see the IRGC (Revolutionary Goards) and MOIS (Ministry of Intelligence and Security) running off and doing things that both the President and Ministry of Foreign Affairs people had no idea of. Even now (with a hardliner as President) the MFA and the IRGC/MOIS seem to running entirely different policies in Afghanistan.

Ahh, the foreign policy challenges caused by an ideological leadership, large national security establishment, bureaucratic politics, and a government system based on a complex system of constitutional checks and balances

Back in the Khatemi days, and through 2001-04, I think it probably was possible to do a deal with Iran on shared strategic interests. Now I doubt it (although its still worth engaging in dialogue).