diff --git a/services/univention-s4-connector/modules/univention/s4connector/__init__.py b/services/univention-s4-connector/modules/univention/s4connector/__init__.py index a1ef180c33..36e1db546c 100644 --- a/services/univention-s4-connector/modules/univention/s4connector/__init__.py +++ b/services/univention-s4-connector/modules/univention/s4connector/__init__.py @@ -837,8 +837,8 @@ class ucs: change_type = "modify" ud.debug(ud.LDAP, ud.INFO, "__sync_file_from_ucs: object was modified") if old_dn and not old_dn == dn: + change_type = "move" ud.debug(ud.LDAP, ud.INFO, "__sync_file_from_ucs: object was moved") - # object was moved new_object = {'dn': unicode(dn, 'utf8'), 'modtype': change_type, 'attributes': new} old_object = {'dn': unicode(old_dn, 'utf8'), 'modtype': change_type, 'attributes': old} if self._ignore_object(key, new_object): @@ -862,7 +862,7 @@ class ucs: return True else: if old_dn and not old_dn == dn: - change_type = "modify" + change_type = "move" ud.debug(ud.LDAP, ud.INFO, "__sync_file_from_ucs: object was moved") else: change_type = "add" @@ -885,7 +885,7 @@ class ucs: else: object = {'dn': unicode(dn, 'utf8'), 'modtype': change_type, 'attributes': new} - if change_type == 'modify' and old_dn: + if change_type in ('modify', 'move') and old_dn: object['olddn'] = unicode(old_dn, 'utf8') # needed for correct samaccount-mapping if not self._ignore_object(key, object) or ignore_subtree_match: @@ -1497,6 +1497,7 @@ class ucs: ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs ignored, sync_mode is %s" % self.property[property_type].sync_mode) return True + # Update modtype if necessary ucs_object_dn = object.get('olddn', object['dn']) old_object = self.get_ucs_object(property_type, ucs_object_dn) if old_object and object['modtype'] == 'add': diff --git a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py index ba9d456dee..303d42338b 100644 --- a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py +++ b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py @@ -2499,7 +2500,7 @@ class s4(univention.s4connector.ucs): # # ADD # - if (object['modtype'] == 'add' and not s4_object) or (object['modtype'] == 'modify' and not s4_object): + if not s4_object and object['modtype'] in ('add', 'modify', 'move'): ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: add object: %s" % object['dn']) ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: lock UCS entryUUID: %s" % entryUUID) @@ -2602,7 +2603,7 @@ class s4(univention.s4connector.ucs): # # MODIFY # - elif (object['modtype'] == 'modify' and s4_object) or (object['modtype'] == 'add' and s4_object): + elif s4_object and object['modtype'] in ('add', 'modify', 'move'): ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: modify object: %s" % object['dn']) ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: old_object: %s" % old_ucs_object) ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: new_object: %s" % new_ucs_object)