The Outcast - S5-E17
Deanna Troi: All right. This hand, the game is "Federation Day."
Worf: What is that?
Troi: Well, the Federation was founded in 2161. So...twos, sixes, and aces are wild.
Worf: That is a woman's game.
Troi: Oh? Why's that?
Worf: All those wild cards. They support a weak hand. A man's game has no wild cards.
Beverly Crusher: Let me get this straight. You're saying it's a woman's game because women are weak and need more help?
Worf: Yes.
Answer: Yes. The doors to the holodecks can be locked when in use by anyone aboard the Enterprise so they couldn't be disturbed. However, high ranking officers like Captain Picard could override the doors as it's seen that overrides are in use even for the crews quarters. Even Barclay, when he's indulging in one of his fantasies could have the doors to the holodeck unlocked by an override code.