It is narrated from Sayyiduna Anas (may Allah be pleased with him) that he said: "When we pledged allegiance to the Messenger of Allah (peace and blessings be upon him) to hear and obey, he (peace and blessings be upon him) would say (prompting us): 'In what you are able.'"
Attab, the freed slave of Hurmuz (may Allah have mercy on him), also narrated it from Sayyiduna Anas (may Allah be pleased with him) in a similar way.
Something like it is also narrated in the Sahih (al-Bukhari and Muslim) from Sayyiduna Jarir bin Abdullah (may Allah be pleased with him).