skip to Main Content

I created an OpenLDAP server on Ubuntu 22.04, and created users but forgot to add them to a organizational unit (ou). How can I associate them all to an ou now ?
The actual server looks like this:

dn=company
    ou=Users
    uid=user1
    uid=user2
    uid=user3
    ...

What I would like is:

dn=company
    ou=Users
        uid=user1
        uid=user2
        uid=user3
        ...

Concretely, I would like to go from this:

uid=user1,dc=example,dc=fr

to this:

uid=user1,ou=Users,dc=example,dc=fr

2

Answers


  1. Chosen as BEST ANSWER

    Actually I just found an answer on my own. I simply did a LDIF file modify.ldif:

    dn: uid=user1,dc=example,dc=fr
    changetype: modify
    add: ou
    ou: Users
    

    And then ldapmodify -x -D cn=admin,dc=example,dc=fr -W -f ./modify.ldif


  2. Adding an ou attribute to the entry is one thing, moving the entry in the DIT is another thing. For the latter, you need to use the newsuperior directive.

    • Using ldapmodify -f with changetype: (modrdn|moddn) :

      dn: uid=user1,dc=example,dc=fr
      changetype: modrdn
      # rdn unchanged
      newrdn: uid=user1
      # deletes old entry
      deleteoldrdn: 1
      # adds to Users hierarchy
      newsuperior: ou=Users,dc=example,dc=com
      
    • Using ldapmodrdn -r -s <newsuperior> <dn> <newrdn> :

      ldapmodrdn -r -s "ou=Users,dc=example,dc=com" "uid=user1,dc=example,dc=fr" "uid=user1"
      
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search