Narrated Anas bin Malik:
While we were sitting with the Prophet in the mosque, a man came riding on a camel. He made his camel kneel down in the mosque, tied its foreleg and then said: “Who amongst you is Muhammad?” At that time the Prophet was sitting amongst us (his companions) leaning on his arm. We replied, “This white man reclining on his arm.” The an then addressed him, “O Son of ‘Abdul Muttalib.”
The Prophet said, “I am here to answer your questions.” The man said to the Prophet, “I want to ask you something and will be hard in questioning. So do not get angry.” The Prophet said, “Ask whatever you want.” The man said, “I ask you by your Lord, and the Lord of those who were before you, has Allah sent you as an Apostle to all the mankind?” The Prophet replied, “By Allah, yes.” The man further said, “I ask you by Allah. Has Allah ordered you to offer five prayers in a day and night (24 hours).? He replied, “By Allah, Yes.” The man further said, “I ask you by Allah! Has Allah ordered you to observe fasts during this month of the year (i.e. Ramadan)?” He replied, “By Allah, Yes.” The man further said, “I ask you by Allah. Has Allah ordered you to take Zakat (obligatory charity) from our rich people and distribute it amongst our poor people?” The Prophet replied, “By Allah, yes.” Thereupon that man said, “I have believed in all that with which you have been sent, and I have been sent by my people as a messenger, and I am Dimam bin Tha’laba from the brothers of Bani Sa’d bin Bakr.”
“I have been sent by my people as a messenger.” Meaning, whatever the Prophet (SAW) had said yes to, he’d convey it to the people. Note that Prophet (SAW) didn’t exactly say those things, he only said ‘yes’ to Dimam’s questions.
This Hadith teaches us that we can quote a person even if they said yes to something. For example:
A asks B: ‘Can we go?’
A says to C: ‘B said we can go.’
Get it? B didn’t say ‘we can go’, he only said yes. But A is quoting him.
This is allowed. :)