My one year old pup loses it the second she hears the door. She barks deeper than usual and will sprint toward the door if possible. If she gets the command "It's okay" from me she'll usually stop barking. If it's a roommate or someone she knows, she switches from being a guard dog to the most excited happy dog ever.
Now, if I'm sleeping or unaware, it's an entirely different situation. If we're taking a long car ride and I pull over for a nap, she sits in the passenger seat and watches everyone/everything. If someone gets 5-10 feet from the car she starts growling. If they come any closer and she starts barking and wakes me up. If I'm sleeping in my room and someone tries to open my door without permission she stops that in a hurry. It's only happened a couple times since I fully expect any roommate to knock before opening my door if it's closed, but when it has happened, she made sure that no one was allowed to come in my room unless I woke up and told her "it's okay". One time visiting my parents at their house my mom (who my dog loves, although she hasn't spent a lot of time with her) went to open the door unannounced and like other times, the guard dog kicked in. I woke up to my mom laughing while yelling through the door "this is MY house!". Once I rolled out of bed and told her it was alright, she switched to being excited to go out and see my mom, and proceeded to sprint out the door to her to say hi.. and pee on her foot by accident.