Cool Solution - Sync Users and Groups into a second Domain



This article describes how to import users, simple authentication accounts and groups from one domain into another 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.

Warning: Existing users, simple authentication account and groups on the target system might be overwritten by this synchronization system. This solution offers a One-Way Synchronization Service, which means that objects created locally inside the target LDAP system are not protected.


Please note that the target system needs the same Mail Domains to be able to import Users with set E-Mail addresses. These can be easily created through the UMC module Mail with the Mail domain object type.

Also all Containers and Organisational Units containing to be synced objects have to be manually created on the target system.

If needed, it is additionally possible to synchronize User Certificates from the Cool Solution - Creation and management of user and Windows certificates. For this to work, the target system at minimum needs the package 'univention-ldap-usercert’ installed. Additionally, the feature has to be enabled through UCR attribute ldap/sync/certificates on the target system.

Note that currently the following attributes are synchronized:

  • Birthdate
  • Description
  • Display name
  • First name
  • Last name
  • Primary e-mail address
  • Password
  • Title
  • User name
  • User Certificate (see above)


To install the packages you first need to enable the Cool Solution repository.

For the basic functionality there are two packages. One on the source and one on the destination system.

Install the destination package on the target UCS system:

univention-install univention-user-group-sync-dest

This package will create a local service user called ‘ucs-sync’, which the leading UCS system will transfer it’s data through. A password will be generated and written to /etc/univention-user-group-sync-dest.secret, as the leading system needs to create a SSH connection during it’s package installation for one time. Afterwards, the password isn’t needed anymore. The leading UCS system will authorize itself through an identity key.

Now, install the source package on the leading UCS system. If you want the package to determine which objects to sync by a specific LDAP attribute added to user and group objects, instead of either syncing all or using a LDAP filter, read and execute the steps in this paragraph Activate sync for objects by LDAP attribute first.

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

After the installation the hostname or IP address of the target UCS system has to be configured. Further, the SSH identity file of the user ‘ucs-sync’ has to be transferred to the destination system to enable the sync mechanism.

Copy the identity file. Replace with the IP or hostname of your destination host. You will be prompted for the password of the user ucs-sync on the destination host, which can be found in the file /etc/univention-user-group-sync-dest.secret on the destination host. This command must be executed on the source host.

ssh-copy-id -i /var/lib/univention-user-group-sync/.ssh/id_rsa -o StrictHostKeyChecking=no -o PubkeyAuthentication=no ucs-sync@"DESTINATION HOST"

Set the destination the sync mechanism shall use. This has to be executed on the source host. Replace “DESTINATION HOST” with the IP or hostname of your destination host.

ucr set ldap/sync/destination="DESTINATION HOST"

After successful installation and configuration, the univention-directory-listener service will automatically create files for all user and group objects below the LDAP base. Afterwards, every object change will be tracked.

These files are automatically transferred by a cron job of the leading UCS system and imported again through another cron job of the target UCS system. Both cron jobs are executed every 5 minutes, which can be changed below.

The temporary files can be found in folder /var/lib/univention-user-group-sync/, if needed.

Advanced Configuration

Filter the LDAP objects to be synchronized

By default, all user and group objects below the LDAP base will be synchronized. It is possible to limit the range to be synchronized with an LDAP filter set through the UCR attribute ldap/sync/filter. Note: The LDAP filter set won’t replace the default filter, but append to it as a second filter.

The default filter: (&(|(&(objectClass=posixAccount)(objectClass=shadowAccount))(objectClass=univentionMail)(objectClass=sambaSamAccount)(objectClass=simpleSecurityObject)(objectClass=inetOrgPerson)(objectClass=univentionGroup))(!(objectClass=univentionHost))(!(univentionObjectFlag=hidden))(!(uidNumber=0))(!(uid=*$))).

Activate sync for objects by LDAP attribute

There is a schema extension which adds a boolean attribute to users and groups. This appears in the UMC in the tab Advanced settings as a checkbox. It can be used to activate certain objects for the sync without modifying the configured LDAP filter every time.

Please note that if the checkbox is activated after an object has been created, a resync for the univention-user-group-sync listener module is performed and saving the object will therefore take a bit longer than usual. Resync means that all objects relevant for the univention-user-group-sync listener module are fed to it again. This is required because the listener module would otherwise not know of an Add operation for the object that was just activated for the sync, only of an Modify operation. Of course this Modify would fail on the destination system because the object has not yet been created there. So with this resync we make sure that all objects are actually created before the script tries to modify them with new values.

Please note also that you don’t need to install univention-user-group-sync-source-schema on the destination system. The attribute and objectClass contained in this package are removed from the objects before they are written to the destination LDAP.

To use this feature a new package must be installed and the LDAP filter used by univention-user-group-sync-source must be modified on the source system:

univention-install univention-user-group-sync-source-schema
ucr set ldap/sync/filter="(univentionUserGroupSyncEnabled=TRUE)"

Remove attributes/objectClasses before sync

If you have LDAP schemata that aren’t installed in the destination domain in your source domain, you might want to remove attributes and object classes of these schemata from objects before they’re being synced. The import of objects with attributes or object classes from schemata that aren’t installed will fail in the destination domain.

Use the following UCR variables on the source system to configure the removal of a comma-separated list of attributes/object classes:

ucr set ldap/sync/remove/objectClass="foo,bar"
ucr set ldap/sync/remove/attribute="foo,bar"

Map source LDAP base(s) to destination OU(s)

By default all objects are created in the destination system in the same position in the LDAP tree as on the source system. Only the LDAP base is changed.
You can also configure a mapping of source LDAP bases to OUs on the destination system to have the objects from a certain LDAP base created below an OU. This mechanism is configured via UCR on the destination system:

ucr set ldap/sync/mapping/base2ou/=""

Note that dc= must be removed and ,dc= must be changed to a dot. E.g.:

dc=ucs,dc=foobar becomes ucs.foobar

So to create objects coming from the LDAP base dc=ucs,dc=foobar in the OU “foobar” in the destination LDAP tree you’d have to create a variable as follows:

ucr set ldap/sync/mapping/base2ou/ucs.foobar="foobar"

Please note that you need to create the OUs and also any CNs where objects are synced from below the OU manually in the destination LDAP tree. By default those CNs are users and groups.

Adjust the synchronization times

The synchronization processes for data transfer and data import are executed every five minutes on both systems. This means, that it can - in theory - take almost up to 10 minutes for an object to be existent on the destination system after it’s initial creation.

The process timings can be adjusted through UCR attributes. Attribute cron/ldap-sync-src/time is available on the source UCS system to adjust the data transfer process.

The data import process timing can be adjusted through UCR attribute cron/ldap-sync-dest/time.

Resynchronize all Users and Groups

The following command can be used on the source system to regenerate all files for all user and group objects: univention-directory-listener-ctrl resync univention_user_group_sync_source_generate


“LDAP_Error: No such object”

This error occurs if an object couldn’t be created, because a container is missing in the structure below. The object path that was last tried to create can be found either in the log file /var/log/univention/user-group-sync.log or in the first temporary file in folder /var/lib/univention-user-group-sync/
Please manually create all missing container objects in the object’s path.

closed #2