Network unlock code not working I have bought a used Motorola Defy (MB525), rooted, running CyanogenMod 9 (ICS 4.0.4). 

It is locked to work with only a specific carrier. I bought an unlock code, and unaware to this the previous owner got an unlock code from the carrier. Both are the same, so I suppose the code is correct. 

When I insert a GSM SIM card from another carrier and turn on the phone, I get a message that roughly translates to "insert SIM network unlock PIN" (see image below).



When I insert the unlock code, it blinks a message VERY fast, I can't even read it, then it says "failed on requesting network unlock", or something like that.

I have performed this more than 3 times, does it mean my phone is locked forever?

I have also been told to remove CM9 and reinstall the stock ROM in order for the unlock to work, but (1) I have no idea if this would actually help, and (2) I have never changed a ROM before and, althouh I used CM9 to create a nandroid backup, I have no idea how to reinstall CM9 and then restore the backup.
I have followed this guide and my phone is now unlocked.

I wouldn't recommend it for a beginner user, because it involves pretty advanced commands and procedures, and uses ROMs and tools from untrusted sources. Proceed at your own risk! 

The performed steps were basically:


Create a complete nandroid backup on the SD card.
Google for a stock ROM for the specific phone model I owned, and the specific carrier that it is locked to. I found one on a random forum. This is not recommended for obvious security reasons, but I was desperate. If your carrier provides an official stock ROM, I definitely recommend you prefer using it.
Googled for the ADB drivers for my phone model. In this case, the Motorola drivers worked fine.
Connected the phone to my computer and flashed the stock ROM. In my case, this actually downgraded my phone from android 4.0.4 to 2.3.3 and unrooted it.
Performed the unlock procedure using the unlock code I had.
Rooted my phone again, and installed a new recovery menu
Applied the nandroid backup from the recovery menu.


Result:

Phone is back as it was before, but unlocked.