(many people may post in this thread that such and such a thing never happened to them, and I don't doubt the veracity of their claims, but this is a legal question and not an experiential hypothesis)
I really don't like being disagreeable, but It absolutely is the law that every single person that enters a hotel or motel room must provide identification.
It's definitely not up to the hotelier; It's a legal requirement enforced daily by the police.
It's possibly being done electronically these days in some locations, but traditionally the police always make their rounds of hotels and motels In the middle of the night shift.
(I think it's worth noting that hoteliers are requiring visitors to present an ID partially as protection for the person staying in that room, so there can be a follow-up if there's ever some sort of problem with assault or theft.)
The person on duty at the lodgings provides a completed Vietnam government Form NA17 listing all of the registered guests in that room.
Before I was married, if I wanted to bring a woman back to my room in my hotel (as happened in Hà Nội, Đà Nẵng, Hội An, Quy Nhơn, Nha Trang, Mũi Né, Vũng Tàu, HCMC and Phú Quốc) the front desk clerk would ask for her ID and hold it while she was visiting me in my room.
It was that same exact pattern every single time I attempted to have a woman WHO WASN'T REGISTERED IN THE ROOM WITH ME visit me there.
When I was actually traveling with a woman to whom I wasn't married, we were both asked for our IDs when we checked into the room and we were both registered as occupants of the room.
Now that I am married to a Vietnamese woman and travel with her often, The clerks at the various hotels ALWAYS follow the requirements of the law and ask for (nicely demand) official identification from both of us.
MONTHLY RENTALS MAY HAVE DIFFERENT REQUIREMENTS ACCORDING TO YOUR LEASE.
However it's becoming pretty common for the lease to specify ALL of the legal residents of the house or apartment and forbid anyone else staying overnight; So you can't even have a foreigner family visitor stay overnight in your house legally without the permission of the landlord and the registration of the visitor by the landlord with the police.
One factor that's going to affect the enforcement of the law or the contract by the landlord will be if the landlord is in residence or nearby as opposed to being absentee somewhere far away from the place you are renting.
In Vũng Tàu (In the apartment house owned by Ciambella's nephew) I was always required to have my guest show their ID to the landlord the first time that they came to visit me.
I'm pretty sure they made a photocopy.
After that first time, they never required that the ID be presented.
Our current house lease in Đà Nẵng is controlled by the brother of the landlord who lives in Hội An.
In the required bilingual contract, it quite specifically states that we cannot have any overnight guests in our house, other than me and my wife and my two bonus daughters who are all registered with the police at this address and included in the original lease; NO EXCEPTIONS.