The Prophet ﷺ said: When one of you comes to the cattle, he should seek permission of their master if he is there; if he permits, he should milk (the animals) and drink. If he is not there, he should call three times. If he responds, he should seek his permission; otherwise, he may milk (the animals) and drink, but should not carry (with him).
أَنَّ نَبِيَّ اللَّهِ ﷺ قَالَ إِذَا أَتَى أَحَدُكُمْ عَلَى مَاشِيَةٍ فَإِنْ كَانَ فِيهَا صَاحِبُهَا فَلْيَسْتَأْذِنْهُ فَإِنْ أَذِنَ لَهُ فَلْيَحْلِبْ وَلْيَشْرَبْ فَإِنْ لَمْ يَكُنْ فِيهَا فَلْيُصَوِّتْ ثَلاَثًا فَإِنْ أَجَابَهُ فَلْيَسْتَأْذِنْهُ وَإِلاَّ فَلْيَحْتَلِبْ وَلْيَشْرَبْ وَلاَ يَحْمِلْ