Sayyiduna Abu Sa'id Khudri (may Allah be pleased with him) narrates that the Prophet Muhammad (peace and blessings be upon him) said: "When a person comes to the herders of camels (i.e., to the grazing camels), he should call out loudly three times: 'O herders of camels!' If they respond to him, then it is fine; otherwise, he may milk the camels and drink. And when a person comes to a garden, he should call out loudly three times: 'O people of the garden!' If they respond to him, then it is fine; otherwise, he may eat (dates from the garden), but he must not take anything away with him." The narrator states: The Prophet Muhammad (peace and blessings be upon him) said: "Hospitality is for three days; whatever is beyond that is charity."
(Imam Ibn Hibban, may Allah have mercy on him, says:) The reason for this ruling is hidden in this narration, and that is the person being in a state of necessity and in need of these things so that his life is not lost. If a person has the means and ability (then he cannot take these things without the permission of the owners)."
Hadith Referenceصحیح ابن حبان / كتاب الأطعمة / 5281
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح لغيره - «الإرواء» (8/ 160 - 161)، «البيوع».فضيلة الشيخ العلّامة شُعيب الأرناؤوطحديث صحيح