Firstly: it is disliked for a person to urinate into a hole or opening in the ground.
Ibn Qudamah said: It is disliked to urinate into a crack or opening (in the ground and the like).
End quote from Al-Mughni, 1/225.
That is because of the report narrated by Qatadah from `Abdullah ibn Sarjis, which says that the Messenger of Allah (blessings and peace of Allah be upon him) forbade urinating into holes.
It was narrated by Abu Dawud (29) and an-Nasa’i (34). It was classed as authentic by Ibn Khuzaymah, Ibn as-Sakan, an-Nawawi in Al-Khulasah (1/156), Ibn Kathir in Irshad al-Faqih (1/56) and Ibn Mulaqqin in Al-Badr al-Munir (2/321).
Some scholars of hadith [such as Shaykh al-Albani and others] had some reservations about this hadith, because Qatadah did not hear directly from `Abdullah ibn Sarjis.
It was narrated from Imam Ahmad ibn Hanbal that he said: I have no knowledge about Qatadah narrating from any of the Companions of the Messenger of Allah (blessings and peace of Allah be upon him) except from Anas.
It was said to him: What about Ibn Sarjis?
It is as if he did not see him, in the sense that he did not hear the hadith from him.
End quote from Al-Marasil by Ibn Abi Hatim ar-Razi (p. 29).
Ibn Daqiq al-Eid said: There is nothing in what Ahmad said about the hadith to confirm that there was any interruption in its isnad.
End quote from Al-Badr al-Munir, 2/ 323.
This is supported by the fact that there was narrated from him (Qatadah) that which confirmed that he did hear it from him. In Al-`Ilal wa Ma`rifat ar-Rijal by `Abdullah (3/86), it says: I said to my father: Did Qatadah hear [hadith] from `Abdullah ibn Sarjis?
He said: It seems that way. End quote.
In Al-`Ilal (3/284), it says: It was said [that is, to Imam Ahmad]: Did Qatadah hear [hadith] from `Abdullah ibn Sarjis? He said: Yes. End quote.
Ibn al-Mulaqqin said: It is proven that Qatadah heard [hadith] from `Abdullah ibn Sarjis… `Ali ibn al-Madini said: Qatadah heard [hadith] from `Abdullah ibn Sarjis.
It was narrated from Abu Hatim az-Razi that he said: Qatadah did not meet any of the Sahabah except Anas ibn Malik and `Abdullah ibn Sarjis.
Al-Hakim Abu `Abdillah said in Al-Mustadrak: There may be someone who is confused and thinks that Qatadah did not mention that he heard it from `Abdullah ibn Sarjis, and that is not far-fetched.
End quote from Al-Badr al-Munir, 2/323).
Shaykh Ibn `Uthaymin said: The least that can be said (about the hadith) is that it is sound (hasan), because the scholars accepted it and quoted it as evidence.
End quote from Ash-Sharh al-Mumti` (1/120).
The word translated here as hole refers to a hole in a wall or in the ground.
And it was said that it refers to the hole dug by vermin and wild carnivores for themselves.
End quote from Hashiyat as-Suyuti `ala Sunan an-Nasa’i (1/30).
That is, it refers to holes in the ground which are dug by some animals, or by some vermin and creatures that live in the ground, which they enter and stay there.
The disapproval of urinating into holes is something on which there is consensus among the jurists, as Imam an-Nawawi stated in Al-Majmu` (2/86).
In Al-Mawsu`ah al-Fiqhiyyah (34/17) it says: It is disliked to urinate into a hole or burrow, according to the consensus of the four madhhabs… because there may come out of the hole a creature that may sting or cause the urine to splash back. An-Nawawi said: This is a matter that is agreed upon, and it is disliked in the sense that it is inappropriate. Al-Bujayrimi, who was a Shafa`i, said: It is prohibited in the case where one thinks it most likely that there is an animal in the hole that is to be protected according to Islamic teachings that could be harmed or die as a result of that. End quote.
Secondly: There are two reasons for this prohibition
1- It may be the abode of harmful vermin, and the one who does that cannot be sure that no harm will come to him from them.
End quote from `Awn al-Ma`bud (1/51).
Shaykh Ibn `Uthaymin said: There is the fear that there may be something living in the hole and you would make its home uninhabitable, or it may come out whilst you are still urinating and harm you, or perhaps you may get up quickly and you will not be able to avoid getting some drops of urine on you.
End quote from Ash-Sharh al-Mumti` (1/120).
Or perhaps the one who does that may see a snake of some kind and panic, and that may cause him harm by interrupting his urination or cause some other kind of physical harm.
2- Holes may also be dwelling places of the jinn, and according to a report narrated by Abu Dawud: They said to Qatadah: Why is it disliked to urinate into holes?
He said: It was said that they are dwelling places of the jinn.
Al-Hakim said: I cannot confirm whether or not they are dwelling places of the jinn, because this is something that Qatadah said [and it is not a hadith].
End quote from Al-Mustadrak `ala as-Sahihayn (1/297).
Many historians stated that the chief of al-Khazraj, Sa`d ibn `Ubadah (may Allah be pleased with him), travelled from Madinah after the death of the Messenger of Allah (blessings and peace of Allah be upon him) to Hawran, where he settled. One day he sat and urinated into a hole in the ground, and as soon as he finished urinating, he fell down dead.
The people of Madinah did not know that he had died until they heard one of the jinn speaking in a well, saying in verse:
We have killed the leader of Khazraj, Sa`d ibn `Ubadah.
We struck him with two arrows and we did not miss his heart.
When the people heard that, they kept that date in mind, and later on they found out that it was the day on which he died.
This story – even though the scholars of hadith had reservations about its chain of narration – is well known to the historians, to the extent that Ibn `Abd al-Barr said: They did not disagree that he was found dead in a place where he used to bathe, and that his body had turned green.
End quote from Al-Isti`ab fi Ma`rifat al-As-hab (2/599).
Thirdly: the scholars differed regarding this prohibition and whether it applies to urinating directly into a bathroom drain or not?
Some of them said that the prohibition includes that. Ibn Muflih said: There is no difference between urinating into a drain or elsewhere.
End quote from An-Nukat wal-Fawa’id (1/9).
Others said that it does not include that, because [the drain] is prepared for that purpose, as Ibn `Abidin said in his Hashiyah (33/59), and this hadith refers to that which is not made for that purpose, unlike a drain, as appears to be the case. End quote.
Ad-Damiri, who was a Shafa`i, said: It should be deemed to be prohibited because of the clear prohibition, unless [the hole] is made for that purpose, in which case it is not prohibited or disliked.
End quote from An-Najm al-Wahhaj fi Sharh al-Minhaj (1/292).
This second view is the more correct one, because the reason for which it was prohibited to urinate into holes is not applicable in this case.
And Allah knows best.