24:27 [an-Nur, Medina 102]
O YOU who have attained to faith! Do not enter houses other than your own unless you have obtained permission and greeted their inmates. This is [enjoined upon you] for your own good, so that you might bear [your mutual rights] in mind. 33
24:28
Hence, [even] if you find no one within [the house], do not enter it until you are given leave; 34 and if you are told, "Turn back," then turn back. This will be most conducive to your purity; and God has full knowledge of all that you do.
24:29
[On the other hand,] you will incur no sin if you [freely] enter houses not intended for living in but serving a purpose useful to you: 35 but [always remember that] God knows all that you do openly, and all that you would conceal.
[[Asad’s notes - 33 This categorical prohibition connects with the preceding passages inasmuch as it serves as an additional protection of individuals against possible slander. In its wider purport, it postulates the inviolability of each person's home and private life. (For the socio-political implications of this principle, see State and Government in Islam, pp.84 if.)
34 I.e., by the rightful owner or caretaker.
35 Lit., "uninhabited houses wherein there are things of use (mata 1 ) for you". In the consensus of all the authorities, including the Companions of the Prophet, this relates to buildings or premises of a more or less public nature, like inns, shops, administrative offices, public baths, etc., as well as to ancient ruins. ]]
Ali’s version
يَا أَيُّهَا الَّذِينَ آمَنُوا...
24: 27. O ye who believe!
... لَا تَدْخُلُوا بُيُوتًا غَيْرَ بُيُوتِكُمْ حَتَّى تَسْتَأْنِسُوا وَتُسَلِّمُوا عَلَى أَهْلِهَا...
enter not houses other than your own, until ye have asked permission and saluted those in them:
...ذَلِكُمْ خَيْرٌ لَّكُمْ لَعَلَّكُمْ تَذَكَّرُونَ ﴿٢٧﴾
that is best for you in order that ye may heed (what is seemly).
C2980. The conventions of propriety and privacy are essential to a refined life of goodness and purity.
The English saying that an Englishman's home is his castle, suggests a certain amount of exclusiveness and defiance.
The Muslim principle of asking respectful permission and exchanging salutations ensures privacy without exclusiveness, and friendliness without undue familiarity.
فَإِن لَّمْ تَجِدُوا فِيهَا أَحَدًا فَلَا تَدْخُلُوهَا حَتَّى يُؤْذَنَ لَكُمْ...
28. If ye find no one in the house, enter not until permission is given to you:
C2981. That is, if no one replies;
- there may be people in the house not in a presentable state. Or,
- even if the house is empty, you have no right to enter it until you obtain the owner's permission, wherever he may be.
The fact of your not receiving a reply does not entitle you to enter without permission. You should wait, or knock twice or three times, and withdraw in case no permission is received.
If you are actually asked to withdraw, as the inmates are not in a condition to receive you, you should a fortiori withdraw, either for a time, or altogether, as the inmates may wish you to do.
Even if they are your friends, you have no right to take them by surprise or enter against their wishes. Your own purity of life and conduct as well as of motives is thus tested.
...وَإِن قِيلَ لَكُمُ ارْجِعُوا فَارْجِعُوا...
if ye are asked to go back, go back:
...هُوَ أَزْكَى لَكُمْ...
that makes for greater purity for yourselves:
...وَاللَّهُ بِمَا تَعْمَلُونَ عَلِيمٌ ﴿٢٨﴾
and Allah knows well all that ye do.
لَّيْسَ عَلَيْكُمْ جُنَاحٌ أَن تَدْخُلُوا بُيُوتًا غَيْرَ مَسْكُونَةٍ فِيهَا مَتَاعٌ لَّكُمْ...
29. It is no fault on your part to enter houses not used for living in, which serve some (other) use for you:
C2982. The rule about dwelling-houses is strict, because privacy is precious, and essential to a refined, decent, and well-ordered life.
Such a rule of course does not apply to houses used for other useful purposes, such as an inn or caravanserai, or a shop, or a warehouse. But even here, of course, implied permission from the owner is necessary as a matter of common-sense.
The question in this passage is that of refined privacy, not that of rights of ownership.