Removing the sim lock *with* the code
Without going into the technical details, iOS ships in a deactivated state and needs to contact an activation server to determine the carrier and locking status each time the device is restored.

iTunes performs the unlocking of all phones less than iOS 5. With iOS5, the device can self activate or activate through iTunes.

When a device is sold, it enters the database as an unlocked device or a locked device. You need the entity that has a lock on your device to update this database. It doesn't really matter if they type it into their system or pass a message to Apple that the device should now be unlocked, but iOS doesn't seem to have a place to enter a unlock code for DIY unlocking and instead depends on the activation process to determine GSM lock status.



I haven't seen it documented anywhere, but my presumption is that Apple operates the service that determines which phone on a serial number / IMEI basis should be locked or unlocked. Given the millions of devices this system is surely automated and authority to make changes to the database is delegated through to the carriers to handle their own unlock requests.



Even here in the US where our Library of Congress has stated for the record that consumers are allowed by law to unlock their devices in certain circumstances, I have yet to see a documented case where someone actually got AT&amp;T to perform a true unlock as described above.