Sayyiduna Muhajir bin Qunfudh (may Allah be pleased with him) narrates: He came to the service of the Prophet Muhammad (peace and blessings be upon him). The Prophet (peace and blessings be upon him) was performing ablution at that time. He greeted the Prophet (peace and blessings be upon him) with salam, but the Prophet (peace and blessings be upon him) did not reply to his salam. When he completed his ablution, he (replied to the salam and) explained with an excuse, saying: "I did not like to mention Allah Almighty while I was in a state of impurity." (There is doubt about one word here according to the narrator.) Hasan al-Basri used to give fatwa according to this narration.
(Imam Ibn Hibban, may Allah have mercy on him, says:) The words of the Prophet (peace and blessings be upon him), "I disliked mentioning Allah Almighty while I was in a state of impurity," mean (the intention of attaining) virtue, because remembering Allah in a state of ablution is more virtuous. It is not that the Prophet (peace and blessings be upon him) disliked it because it is unlawful.