Chapter: Laws of ehram
Wet Dream (or Ghusl [taking bath] becomes obligatory, without intercourse) and Ihram
(1) Due to the wet dream (taking bath becomes obligatory, without intercourse) if it becomes obligatory to take bath, then there is no Kaffarah for this. (Bahar-e-Shariyat, Volume 1, Part 6, Page 1173).
(2) If any Muhrim tries to masturbate and the semen comes out, then Dam becomes obligatory. If no semen comes out it is MukruhTahrimi (abomination to the higher level or an act nearing to haraam) (Bahar-e-Shariyat, Volume 1, Part 6, Page 1102). This type of action in ihram amounts to a major sin.
Keep in mind that this act in general life style also not permissible and haraam. The person who masturbates has been termed as ‘Accursed’ (‘la’nati’) in holy hadith.