Synchronizing users from LDAP to Active Directory

Since we decided to implement Active Directory in our company to take control of user’s desktops there rose up the idea of synchronizing users between LDAP and AD. The optimal solution would be two-way synchronization between our LDAP server and Active Directory server including user login, email, full name and his password.

After we had made some evaluation what projects are capable of this task with our configuration, we ended up only with LSP project which we finally found sort of clumsy and troublesome to configure besides there would be another issue regarding password synchronization anyway. Password synchronization turned up to be a big problem in general and is also mentioned by LSC project:

Synchronizing passwords with Active Directory is a common requirement, but generally a tricky subject. LSC does not solve this problem for you, but can help you achieve your goal. In particular:

LSC can write a password to Active Directory, given the original password in clear text (there is no way to update a password in AD if you only have a hashed password, in MD5 or SHA, for example).

LSC cannot read passwords from Active Directory

We also came to conclusion it would be easier task for us to synchronize users from/to 386 Directory which has some build-in AD synchronization feature (don’t know how much would it helped us) but we actually didn’t want to migrate from OpenLDAP to 386 Directory server also given the fact we already had complex master-slave synchronizations setup.

At this point we abandoned the idea of two-way synchronization between LDAP and AD and tried to find the easiest way to synchronize user’s data from LDAP to AD. This would help us in way that once we would create a new user in LDAP the user’s name, email, login and other data would be created in AD as well. We decided to create new AD accounts with preset passwords which is the only think user would have to change after logging in.

After few days spent by trying to find out what’s the optimal way to manage this task we ended up with pretty simple solution.

Fist thing is to export user’s data from LDAP and prepare a .bat file which can further be run on Windows server to import users to AD. It actually just uses “dsadd” command to import user into AD with appropriate parameters. At the end the character encoding is changed to CP852 to preserve non-ASCII characters in user’s names. This script can be placed to cron and be run regularly so the generated data is still up-to-date