The door switch is located inside the door latch. You can sometimes fix what you describe by spraying WD40 up and in the door latch. Then, open and shut the door/s several times. I had the dome light problem like you describe and was told to by a local mechanic to do the WD40 treatment. I was skeptical, but it worked.
If the doors are locked via the keyless before the doors are closed they will flash to let you know they are locked. the headlights should do the same in this instance.