Cisco Unity Connectin – Import user error

When importing user from LDAP/CUCM, it fails with this error – “A User with the specified extension already exists in the Partition.”

Use the following query to find the stale user or the ghost number

run sql select userid, pkid from enduser where userid = 'JohnD'
userid  pkid                                 
======= ==================================== 
JohnD fc333ee7-8580-d28d-b4f2-4af5260d142f 

run cuc dbquery unitydirdb SELECT ObjectId from vw_User WHERE Alias ='JohnD'
run cuc dbquery unitydirdb select * from tbl_user where ldapccmpkid='fc333ee7-8580-d28d-b4f2-4af5260d142f'
run sql select * from enduserappservermap where fkenduser='fc333ee7-8580-d28d-b4f2-4af5260d142f'
run sql delete from enduserappservermap where fkenduser='fc333ee7-8580-d28d-b4f2-4af5260d142f'


run cuc dbquery unitydirdb select parent_globaluserobjectid, dtmfaccessid, displayname from tbl_DtmfAccessId where DtmfaccessId = '6000'
parent_globaluserobjectid             dtmfaccessid  displayname
------------------------------------  ------------  -----------
88a19b9f-b146-479c-8692-46e4e6bcfba5  6000      null
run cuc dbquery unitydirdb select * from vw_subscriberreference where objectid = '88a19b9f-b146-479c-8692-46e4e6bcfba5'