Sunan an-Nasa'i, Book 39, Hadith 2 (Nasa'i 4160)

It was narrated that 'Ubadah bin As-Samit said:

"We pledged to the Messenger of Allah to hear and obey, both in times of hardship and ease." And he mentioned similarly.