When The Bough Breaks - S1-E17
Continuity mistake: When Wesley is being introduced to the Companion, the camera zooms in to see the entire console up on the full screen with NO hands on it, but when it cuts to a side view, Radue's wife's hands are on the console.
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.