Profile Manager ICCID error during enrollment

February 8, 2014

During enrollment at a client we faced some issues with device unable to completly enroll. After researching some logs we found the cause (and the fix!) of the issue.

Symptom

The device you are trying to enrol in Device Manager will enroll partially, but stays stuck as a New Device

New settings, extra profiles and payloads will not be pushed and remain in de actions queu.

If you look in the console you will find the following error during enrollment:

ActiveRecord::StatementInvalid (PGError: ERROR: duplicate key value violates unique constraint "devices_ICCID_key" DETAIL: Key ("ICCID")=(0000 0000 0000 0000 0000) already exists

Cause

The device you are trying to enroll has been previously enrolled to this specific MDM server although it’s no longer visible in the Profile Manager dashboard. However there is still a record of this device in the Postgres database used by Profile Manager. When trying to enroll the device the system will give an error because the UUID (ICCID) of this device is already registered in the database. This error is causing a “semi-enrollment”.

Fix

To solve the problem you need to remove the record from the Postgres database manually. You can do this via the Terminal.

Connect to the Postgres DB

sudo -u _devicemgr psql device_management

To make sure that you can actually make sense of the database response, please enter the following command:

\x on;

Now you need to find the broken database record by searching for the ICCID wich is causing the errors:

SELECT * FROM devices WHERE "ICCID" LIKE '0000 0000 0000 0000 0000';

Note: You can find the ICCID in the Console app when you’re trying to enroll the device that won’t enroll correctly.

And finally you need to remove the record from the database:

DELETE FROM devices WHERE "ICCID" LIKE '0000 0000 0000 0000 0000';