Yes a restore will do it. But if you know the passcode (which you should as long as it's "secondhand" and not "stolen") you can just go in and disable it in settings. Unless it's got a lock for enterprise settings but that is fairly rare unless you got the phone from a high power exec.