It is narrated from Sayyidah Umm Salamah (may Allah be pleased with her): "The Messenger of Allah (peace and blessings be upon him) came out to the open courtyard of this mosque and called out at the top of his voice: 'Beware! This mosque is not lawful for anyone in a state of major impurity (junub, one on whom ghusl is obligatory) or for a menstruating woman, except for the Prophet (peace and blessings be upon him), his pure wives, Sayyiduna Ali (may Allah be pleased with him), and Sayyidah Fatimah (may Allah be pleased with her), the daughter of Muhammad (peace and blessings be upon him). Take heed! Have I not made their names clear to you, lest you go astray?'" Imam Ibn Majah narrated it in his Sunan through Abu Bakr bin Abi Shaybah and Muhammad bin Yahya, from Abu Nu'aym, from Ibn Abi Ghaniyyah, but without the words from "except for the Prophet (peace and blessings be upon him)" to the end. Imam Abu Dawud narrated it by way of Aflat bin Khalifah, from Jasrah, from Sayyidah Aishah (may Allah be pleased with her), so it is a shahid (supporting narration) for the hadith of Sayyidah Umm Salamah (may Allah be pleased with her). Imam al-Bayhaqi narrated it in al-Sunan al-Kubra by way of Muhammad bin Yunus from Abu Nu'aym al-Fadl bin Dukayn, and it was also narrated by way of Isma'il from Jasrah. It also has a shahid from the hadith of Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him), which Imam al-Tirmidhi narrated in his Jami' and declared "hasan gharib".
Hadith Referenceإتحاف الخيرة المهرة بزوائد المسانيد العشرة / كتاب المساجد / 1026