If one effectively guesses the correct passcode to the lock so as to open it without causing any damage and then peacefully enters (seemingly a mere civil trespass) the (previously) secured premises, do they commit any criminal offence?
None, if the intention is merely trespassing, unlike burglary which requires intent to steal, commit criminal damage, or inflict grevious bodily harm or if the building is a protected site - neither of which isn't evident from the question.
Note, for both offences, the actus reus is entry - there is no requirement for any form of "breaking"
Further to ohwilleke's comment, unless the lock is damaged or destroyed etc, then there is no offence of criminal damage
This would be breaking and entering contrary to s. 348 of the Criminal Code.
"Breaking" under this offence means "to break any part, internal or external, or ... to open any thing that is or intended to be used to close or cover an internal or external opening" (s. 321).
A person is deemed to have broken and entered if they "enter without lawful justification or excuse by a permanent or temporary opening" (s. 350). Even entry through an unlocked door, when it is done without consent, is deemed to be breaking and entering. See Todorov c. R., 2015 QCCA 812.
Under s4 of the Inclosed Lands Protection Act 1901:
(1) Any person who, without lawful excuse (proof of which lies on the person), enters into inclosed lands without the consent of the owner, occupier or person apparently in charge of those lands, or who remains on those lands after being requested by the owner, occupier or person apparently in charge of those lands to leave those lands, is liable to a penalty not exceeding …
There is an additional penalty if you don’t close the door when you leave. Because the Act is primarily about protecting agricultural land and leaving gates open can lead to stock wandering but it is applicable to all land.
This answer assumes no intent of wrongdoing other than opening the lock was proven by the prosecution.
Tampering with security devices is a class 4 felony. The bold text below is mine.
(720 ILCS 5/17-11.5) (was 720 ILCS 5/16-22)
Sec. 17-11.5. Tampering with a security, fire, or life safety system.
(a) A person commits tampering with a security, fire, or life safety system when he or she knowingly damages, sabotages, destroys, or causes a permanent or temporary malfunction in any physical or electronic security, fire, or life safety system or any component part of any of those systems including, but not limited to, [...] (a long list of devices) [...].
(b) Sentence. A violation of this Section is a Class 4 felony.
The lock suffered a temporary malfunction, as it was not doing its job of keeping the door closed. The security feature was also sabotaged (though not harmed), not fulfilling its function, when it was left open.
Sabotage is the act of hampering, deliberating subverting, or hurting the efforts of another.
In this case, the efforts of whoever wanted the door to stay locked were sabotaged.
Did the intruder tamper with the lock?
Tampering is an intentional act of interfering improperly or in a harmful manner. [...]
By switching the lock to "open" without permission, the person exposed the secured area to intruders (and became one in the process). Testing combinations until the correct one was entered is an intentional act. The opening of the lock is harmful as it compromises the security of the venue.
The trespasser, aside from civil charges, can also face 1 to 3 years in prison and fines up to USD 25k. (730 ILCS 5/5-4.5-45)
Summary Offences Act 1966, Section 9(1)(e)
without express or implied authority given by the owner or occupier or given on behalf of the owner or occupier by a person authorised to give it or without any other lawful excuse, wilfully enters any private place or Scheduled public place, unless for a legitimate purpose; or
Normally prosecuted as "unlawfully on premises". Note: for whatever reason, section 9 is titled Wilful destruction, damage etc. of property, which makes it a little harder to find. This is a summary offense tried by a magistrate without a jury, so "lawful" and "legitimate" are not complicated legal terms: they limit rather than extend the terms "excuse" and "purpose".