Search code examples
ldapopendjdistinguishedname

Updating a user's DN from using CN to using UID


I am looking for a way to update a user's entry DN from this :

dn: cn=Super,ou=Prod,ou=clients,dc=test,dc=com

To this :

dn: uid=SuperUID,ou=Prod,ou=clients,dc=test,dc=com

Given that my directory has multiple ou's, and some are already using the UID attribute within their DN, so I need to update only this ou. Also, my ldap server is running openDJ.

I've been searching here and somewhere else but I could not find any working answer.

I keep getting this error :

Result Code:  65 (Object Class Violation)
Additional Information:  The modify DN operation for entry [...]  cannot be performed because the change would have violated the server schema: Entry [...] violates the Directory Server schema configuration because it is missing attribute cn which is required by objectclass person

I understand (well, kind of) what this error is telling me, but I cannot find my way around this to fix my problem ...

Thanks


Solution

  • You must use ModDN to rename an entry. But to keep the entry compliant with the schema (as you are changing the naming attribute), you must keep the previous value. The following change will work :

    ldapmodify -D cn=directory\ manager -w password -h localhost -p 1389
    
    dn: cn=Super,ou=Prod,ou=clients,dc=test,dc=com
    changetype: moddn
    newrdn: uid=SuperUID
    deleteoldrdn: false
    

    You can later modify the cn attribute to change its value, using a Modify operation.