This CM query assumes that the UPN is being duplicated in the database but you could change it to user_name0 if that is where the duplicate entries are being found:
select user_principal_name0, count(*) total from v_r_user
group by User_Principal_Name0
having (count(user_principal_name0))>1