Index: modules/univention/s4connector/s4/__init__.py =================================================================== --- modules/univention/s4connector/s4/__init__.py (Revision 60587) +++ modules/univention/s4connector/s4/__init__.py (Arbeitskopie) @@ -2394,8 +2394,16 @@ 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) + try: + ## try to fetch the latest version of the OpenLDAP object + current_ucs_object = self.lo.get(object['dn']) + ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: cur_object: %s" % current_ucs_object) + new_ucs_object = current_ucs_object + except ldap.NO_SUCH_OBJECT: + pass object['old_ucs_object'] = old_ucs_object object['new_ucs_object'] = new_ucs_object + attribute_list = set(old_ucs_object.keys()).union(set(new_ucs_object.keys())) if hasattr(self.property[property_type],"con_sync_function"): self.property[property_type].con_sync_function(self, property_type, object) @@ -2438,9 +2446,12 @@ modify=True if not modify: - ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: no modification necessary for %s" % attribute) + ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: values did not change for %s" % attribute) continue + current_s4_values = set(s4_object.get(s4_attribute, [])) + ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) + # So, at this point we have the old and the new UCS object. # Thus we can create the diff, but we have to check the current S4 object @@ -2456,9 +2467,6 @@ if s4_other_attribute: # in this case we need lists because sets are unorded and the order is important - current_s4_values = set(s4_object.get(s4_attribute, [])) - ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) - current_s4_other_values = set(s4_object.get(s4_other_attribute, [])) ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 other values: %s" % current_s4_other_values) @@ -2480,10 +2488,6 @@ if current_s4_other_values != new_s4_other_values: modlist.append((ldap.MOD_REPLACE, s4_other_attribute, new_s4_other_values)) else: - current_s4_values = set(s4_object.get(s4_attribute, [])) - - ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) - if (to_add or to_remove) and attribute_type[attribute].single_value: modify=False if not current_s4_values or not value: