Cool Solution - Sync Users and Groups into a second Domain

From Univention Wiki

Jump to: navigation, search
Produktlogo UCS Version 4.3

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Packages provided by a Cool Solutions Repository are built by Univention, but will not be maintained. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.
Note: This article is not yet reviewed.

This article describes, how to import Users and Groups from one domain into a second through a synchronization system. The implementation keeps the target system in sync with the source system (One-Way Synchronization).
For this setup to work, the external target system can be unable to reach the internal source system. However, the internal source system must be able to gain SSH access to the target. This solution is especially helpful to keep a server in the DMZ up-to-date with changes to users and groups in an internal, inaccessible UCS environment. Both systems are allowed to have different LDAP bases.


First, you have to install two packets. There is one package each for the source and target systems.

Install the source package on the leading UCS system:

univention-install univention-user-group-sync-source

further, install the sink package on the target UCS system:

univention-install univention-user-group-sync-sink


You can now configure the connection. All configurations can be done through UCR attributes on the UCS source system.
We have a few attributes, that have to be set:

UCR variable Description
ldap/sync/filter LDAP Filter, that will filter all wanted users and groups out of the source system.
Note: If this variable is empty, a default will be used. The standard filter guarantees ensures that all users and groups are syncronized by nothing else:


ldap/sync/address Hostname or IP address of the target UCS system
ldap/sync/user User name for data transfer, with which the software can connect to the target UCS system through SSH
ldap/sync/pwdfile Path to password file for data transfer to the target UCS system, which contains the password of the transfer user

The variable ldap/sync/filter is needed to guarantee, that only Users and Groups are synchronized. It is at the moment not possible to keep anything else synchronized with this Solution. We will use the default filter, which selects all Users and Groups as noted above. We don't have to restrict the selected Objects further in our example.

The source system needs SSH access to transfer data and execute the script delivered by the sink package to the target system. We will use the root user of the target system in our example and store it's password in the /etc folder of the source system:

ucr set ldap/sync/filter="" \
ldap/sync/address="" \
ldap/sync/user="root" \

At last, a cron job has to be created to trigger the synchronization of the two UCS systems. The following two UCR variables can be used to define it:

UCR variable Description
cron/ldap-synchronization/time The cron job time, which specifies the execution time in Cron syntax (default every 5 minutes: */5 * * * *)
cron/ldap-synchronization/command The cron job command, which synchronizes the UCS systems (default: see below)

The following code creates a cron job, which is run every 5 minutes and then synchronizes and imports all LDAP changes to Users and Groups into the target system:

ucr set cron/ldap-synchronization/time="*/5 * * * *" \
cron/ldap-synchronization/command="univention-ssh-rsync \
$(ucr get ldap/sync/pwdfile) --remove-source-files --ignore-missing-args \
/var/lib/univention-user-group-sync-source/* \
$(ucr get ldap/sync/user)@$(ucr get ldap/sync/address):/var/lib/univention-user-group-sync-sink/ \
&& univention-ssh $(ucr get ldap/sync/pwdfile) \
$(ucr get ldap/sync/user)@$(ucr get ldap/sync/address)"

Now, the configuration is done. The source package will write all LDAP changes into files below the /var/lib/univention-user-group-sync-source/ folder, which will be synchronized by the cron job and again be imported by the sink package.

Personal tools