Yesterday's Enterprise - S3-E15
Continuity mistake: In the episode 'Yesterday's Enterprise' (season three, episode 15), watch the final scene with Geordi and Guinan in Ten-Forward. Although time and the universe has returned to normal, Geordi is still wearing the uniform from the alternate timeline (note the sleeve detail, and the extended neck piece).
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.