Bloodlines - S7-E22
Continuity mistake: When Jason and Picard are having a conversation in the holodeck, Jason says "I remember her telling me about all the boys and girls who didn't have anyone to care for them" while looking in the opposite direction of where Picard is sitting. The camera angle changes to a close-up and Jason now has his head turned slightly towards Picard.
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.