The Prophet ﷺ said, "When one of you comes upon a flock of livestock, if its owner is present, let him ask his permission. If he grants permission, let him milk it and drink. If no one is present, let him call out three times. If anyone responds, let him ask his permission. If no one answers, let him milk it and drink, but he must not carry any away."
حدثنا أبو سلمة يحيى بن خلف حدثنا عبد الأعلى عن سعيد عن قتادة عن الحسن
أن النبي ﷺ قال إذا أتى أحدكم على ماشية فإن كان فيها صاحبها فليستأذنه فإن أذن له فليحتلب وليشرب وإن لم يكن فيها أحد فليصوت ثلاثا فإن أجابه أحد فليستأذنه فإن لم يجبه أحد فليحتلب وليشرب ولا يحمل
Its isnad is daif. Abu Dawud narrated it in the Book of Jihad, chapter "Concerning the traveler eating dates and drinking milk," h. 2619, from the hadith of Abdul-Ala bin Abdul-Ala, through this same route. Saeed bin Abu Aruba and Qatada both narrated using "an" (indicating a possible break in the chain). Nevertheless, Hafiz graded it sahih in Fath al-Bari, 5/89. It has a corroborating narration in Ahmad, though its chain is also daif.On this subject there are also narrations from Ibn Umar [mentioned previously at 1287] and Abu Saeed [Ibn Majah, h. 2300].