Sunan an-Nasa'i, Volume 5, Book 39, Hadith 4211 (DarusSalam)

It was narrated that Ibn 'Umar said: "The Messenger of Allah said: 'The Muslim must hear and obey whether he likes it or not, unless he is commanded to commit an act of disobedience. If he is commanded to commit an act of disobedience, then he is not required to hear and obey."'

أَخْبَرَنَا قُتَيْبَةُ، قَالَ حَدَّثَنَا اللَّيْثُ، عَنْ عُبَيْدِ اللَّهِ بْنِ أَبِي جَعْفَرٍ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ عَلَى الْمَرْءِ الْمُسْلِمِ السَّمْعُ وَالطَّاعَةُ فِيمَا أَحَبَّ وَكَرِهَ إِلاَّ أَنْ يُؤْمَرَ بِمَعْصِيَةٍ فَإِذَا أُمِرَ بِمَعْصِيَةٍ فَلاَ سَمْعَ وَلاَ طَاعَةَ ‏" ‏ ‏.‏

sunnah.com