Hadithcore
Al-Adab Al-Mufrad, 1093

Thawban, the mawla of the Messenger of Allah, (ﷺ), related that the Prophet, (ﷺ), said, "It is not lawful for a Muslim man to look inside a house until he has been given permission. If he does so, he has entered. He should not act as the imam of a people and then single himself out for supplication to the exclusion of others. He should not pray while he needs to urinate until he has relieved himself."

حَدَّثَنَا إِسْحَاقُ بْنُ الْعَلاَءِ قَالَ‏:‏ حَدَّثَنِي عَمْرُو بْنُ الْحَارِثِ قَالَ‏:‏ حَدَّثَنِي عَبْدُ اللهِ بْنُ سَالِمٍ، عَنْ مُحَمَّدِ بْنِ الْوَلِيدِ، قَالَ‏:‏ حَدَّثَنَا يَزِيدُ بْنُ شُرَيْحٍ، أَنَّ أَبَا حَيٍّ الْمُؤَذِّنَ حَدَّثَهُ، أَنَّ ثَوْبَانَ مَوْلَى رَسُولِ اللهِ صلى الله عليه وسلم حَدَّثَهُ، أَنَّ النَّبِيَّ صلى الله عليه وسلم قَالَ‏:‏ لاَ يَحِلُّ لِامْرِئٍ مُسْلِمٍ أَنْ يَنْظُرَ إِلَى جَوْفِ بَيْتٍ حَتَّى يَسْتَأْذِنَ، فَإِنْ فَعَلَ فَقَدْ دَخَلَ‏.‏ وَلاَ يَؤُمُّ قَوْمًا فَيَخُصُّ نَفْسَهُ بِدَعْوَةٍ دُونَهُمْ حَتَّى يَنْصَرِفَ‏.‏ وَلاَ يُصَلِّي وَهُوَ حَاقِنٌ حَتَّى يَتَخَفَّفَ‏.‏

References2 variants
In-Book Reference
Book 43, Hadith 43
English Reference
Book 43, Hadith 1093