Sahih Muslim 1839 a
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
عَلَى الْمَرْءِ الْمُسْلِمِ السَّمْعُ وَالطَّاعَةُ فِيمَا أَحَبَّ وَكَرِهَ إِلاَّ أَنْ يُؤْمَرَ بِمَعْصِيَةٍ فَإِنْ أُمِرَ بِمَعْصِيَةٍ فَلاَ سَمْعَ وَلاَ طَاعَةَ "
It has been narrated on the authority of Ibn 'Umar that the Prophet (ﷺ) said:
It is obligatory upon a Muslim that he should listen (to the ruler appointed over him) and obey him whether he likes it or not, except that he is ordered to do a sinful thing. If he is ordered to do a sinful act, a Muslim should neither listen to him nor should he obey his orders.
Full reference and source
Sahih Muslim 1839 a In-book : Book 33, Hadith 61 USC-MSA web (English) : Book 20, Hadith 4533 (deprecated)
View source on Sunnah.com (opens in a new tab)