The Best of Both Worlds (2) - S4-E1
Factual error: Shelby announces the Borg have entered Sector 001, and we get an exterior shot of the Borg ship flying past Saturn. The problem is that the Borg are approaching from the side of the planet illuminated by the sun, meaning they would actually be moving AWAY from Earth rather than toward it.
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.