The Battle - S1-E9
Other mistake: When Capt. Picard gets beamed from The Stargazer back to The Enterprise at the end of the episode, he doesn't lower shields. Also, a Ferengi (DaiMan Bok) beams off the Stargazer onto his Ferengi ship earlier without lowering shields on the Stargazer. (00:35:45 - 00:44:20)
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.