It is narrated from Sayyiduna Samurah bin Jundub (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When one of you comes upon livestock, if he sees their owner among them, let him ask his permission; if he permits him, let him milk and drink. If the owner is not there, let him call out three times; if he comes, let him ask his permission, otherwise let him milk and drink, but he must not carry any away (with him)."
Hadith Referenceالمعجم الكبير للطبراني / باب السين / 6847