Remember Me - S4-E5
Plot hole: When the image of the warp bubble closing in on the superimposed "Enterprise" image, Dr. Crusher asked for it to be the same scale for each image. At the rate the bubble was closing in on the engineering section, it would have been destroyed LONG before the 4 minutes 15 seconds the computer gave for it to be destroyed.
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.