The only officially sanctioned way to unlock an iPhone 4S is to request an unlock code from the mobile carrier. If the phone is eligible to be unlocked, the carrier unlocks the device. When this process is complete, restoring the phone in iTunes unlocks the device.
The phone's owner provides the carrier with the device's IMEI number when requesting an unlock. Each device unlock code is unique, and the carrier uses the IMEI to determine the phone's unlock code. Carriers provide unlock codes to customers who are out of contract. Paying an early termination fee renders an on-contract phone eligible for unlock immediately.
Third-party unlocking software is a violation of Apple's end user license agreement and is not supported by Apple. Installing and using such software voids all manufacturer's warranty coverage on the unlocked device. Third-party services that provide IMEI-based unlocks do not void the phone's warranty but do potentially compromise consumers' personal information; in some cases, third-party IMEI unlocking services illegally access customer account information in an attempt to find unlock codes.
Both types of third-party phone unlock potentially violate carrier agreements. A customer who performs an unauthorized unlock on a contract phone may be liable for breach of contract.