صحيح البخاري Sahih Bukhari كتاب الأحكام The Book of Al-Ahkam (Judgements)
بَابُ هَلْ لِلإِمَامِ أَنْ يَمْنَعَ الْمُجْرِمِينَ وَأَهْلَ الْمَعْصِيَةِ مِنَ الْكَلاَمِ مَعَهُ وَالزِّيَارَةِ وَنَحْوِهِ:

(53) Chapter. Is it legal for the Imam to forbid the criminals and those who commit sin to talk to or visit him, etc.?

1 hadith
Hadith 7225
حَدَّثَنِي يَحْيَى بْنُ بُكَيْرٍ ، حَدَّثَنَا اللَّيْثُ ، عَنْ عُقَيْلٍ ، عَنِ ابْنِ شِهَابٍ ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ عَبْدِ اللَّهِ بْنِ كَعْبِ بْنِ مَالِكٍ ، أَنَّ عَبْدَ اللَّهِ بْنَ كَعْبِ بْنِ مَالِكٍ ، وَكَانَ قَائِدَ كَعْبٍ مِنْ بَنِيهِ حِينَ عَمِيَ ، قَالَ : سَمِعْتُ كَعْبَ بْنَ مَالِكٍ ، قَال : " لَمَّا تَخَلَّفَ عَنْ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فِي غَزْوَةِ تَبُوكَ ، فَذَكَرَ حَدِيثَهُ ، وَنَهَى رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ الْمُسْلِمِينَ عَنْ كَلَامِنَا ، فَلَبِثْنَا عَلَى ذَلِكَ خَمْسِينَ لَيْلَةً ، وَآذَنَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ بِتَوْبَةِ اللَّهِ عَلَيْنَا " .
Narrated `Abdullah bin Ka`b bin Malik: Who was Ka`b's guide from among his sons when Ka`b became blind: I heard Ka`b bin Malik saying, "When some people remained behind and did not join Allah's Apostle in the battle of Tabuk.." and then he described the whole narration and said, "Allah's Apostle forbade the Muslims to speak to us, and so we (I and my companions) stayed fifty nights in that state, and then Allah's Apostle announced Allah's acceptance of our repentance."
Hadith Reference Sahih Bukhari / The Book of Al-Ahkam (Judgements) / Hadith: 7225
Hadith Grading محدثین: أحاديث صحيح البخاريّ كلّها صحيحة