[Samba] Copy additional LDAP attributes on migration from ldap

Trent W. Buck trentbuck at gmail.com
Mon Nov 11 17:12:54 MST 2013

mourik jan heupink <heupink at merit.unu.edu> writes:

> Hi Marc,
>> You can simply work around that. After the migration:
>> - Configure your openLDAP to listen on a different port than 389
>> - Start openLDAP again
>> - Write a simple script that loops through all accounts on your DC.
>> Inside this loop you retrieve the required attributes of these accounts
>> from openLDAP and insert them with ldbmodify to AD.
>> - Shutdown openLDAP
>> Sounds more difficult than it is. 15 mins and it's done, if you know a
>> scripting language.
> And you happen to have such a simple script somewhere on your
> harddisk..? :-)

Something like this (untested):

    ldapsearch -H oldplace mail dn |
    while read attr val
    do  case $attr in
          (dn:)   dn=$val;;
          (mail:) mail=$val
                  printf 'dn: %s\nmail: %s\n\n' "$dn" "$mail";;
    done |
    ldbmodify -H tdb:///path/to/sam.ldb

Rinse and repeat for each attribute you care about.

Write to stdout or a file instead of ldbmodify to review it first.

Dealing with missing objectClass attributes and schemas is left as an
exercise for the reader.  In the former case, you can probably know a
priori that e.g. mail needs objectClass: person and just add that to the

More information about the samba mailing list