كتاب الإمارة
33  
The Book on Government
(8)
Chapter: The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters
(8)
باب وُجُوبِ طَاعَةِ الأُمَرَاءِ فِي غَيْرِ مَعْصِيَةٍ وَتَحْرِيمِهَا فِي الْمَعْصِيَةِ ‏‏
Sahih Muslim 1709 f

This hadith has been narrated on the authority of 'Ubada b. Walid with the same chain of transmitters.

وَحَدَّثَنَاهُ ابْنُ نُمَيْرٍ، حَدَّثَنَا عَبْدُ اللَّهِ، - يَعْنِي ابْنَ إِدْرِيسَ - حَدَّثَنَا ابْنُ عَجْلاَنَ، وَعُبَيْدُ اللَّهِ بْنُ عُمَرَ وَيَحْيَى بْنُ سَعِيدٍ عَنْ عُبَادَةَ بْنِ الْوَلِيدِ، فِي هَذَا الإِسْنَادِ مِثْلَهُ ‏.‏
Reference : Sahih Muslim 1709f
In-book reference : Book 33, Hadith 67
USC-MSA web (English) reference : Book 20, Hadith 4539
  (deprecated numbering scheme)