O you who believe! Enter not houses other than your own, until you have asked permission and greeted those in them, that is better for you, in order that you may remember.
And if you find no one therein, still, enter not until permission has been given. And if you are asked to go back, go back, for it is purer for you, and Allah is All-Knower of what you do.
There is no sin on you that you enter (without taking permission) houses uninhabited (i.e. not possessed by anybody), (when) you have any interest in them. And Allah has knowledge of what you reveal and what you conceal.
Tell the believing men to lower their gaze (from looking at forbidden things), and protect their private parts (from illegal sexual acts, etc.). That is purer for them. Verily, Allah is All-Aware of what they do.[27-30]