Index: replication.py =================================================================== --- replication.py (Revision 71013) +++ replication.py (Arbeitskopie) @@ -693,6 +693,7 @@ def _remove_file(pathname): + ud.debug(ud.LISTENER, ud.ALL, 'replication: removing %s' % (pathname,)) try: os.remove(pathname) except EnvironmentError as ex: @@ -827,7 +828,7 @@ # add if new: - if os.path.exists(CURRENT_MODRDN): + if os.path.exists(CURRENT_MODRDN) and not isinstance(l, LDIFObject): target_uuid_file = os.readlink(CURRENT_MODRDN) old_dn = _read_dn_from_file(CURRENT_MODRDN) @@ -847,12 +848,21 @@ new_dn = ldap.dn.str2dn(dn) new_parent = ldap.dn.dn2str(new_dn[1:]) new_rdn = ldap.dn.dn2str([new_dn[0]]) + + delold = 0 + for old_rdn in ldap.dn.str2dn(old_dn)[0]: + if not old_rdn[0] in new: + ud.debug(ud.LISTENER, ud.ALL, 'replication: new: attr %s not present' % (old_rdn[0],)) + delold = 1 + continue + elif not old_rdn[1] in new[old_rdn[0]]: + ud.debug(ud.LISTENER, ud.ALL, 'replication: new: val %s not present in attr %s' % (old_rdn[1], old_rdn[0])) + delold = 1 + continue + ud.debug(ud.LISTENER, ud.PROCESS, 'replication: rename from %s to %s' % (old_dn, dn)) - l.rename_s(old_dn, new_rdn, new_parent, delold=1) + l.rename_s(old_dn, new_rdn, new_parent, delold=delold) _remove_file(modrdn_cache) - if not isinstance(l, LDIFObject): - old = getOldValues(l, dn) - _modify_object_from_old_and_new(l, dn, old, new) else: # the old object does not exists, so we have to re-create the new object ud.debug(ud.LISTENER, ud.ALL, 'replication: the local target does not exist, so the object will be added: %s' % dn) @@ -927,6 +937,9 @@ reconnect = 1 connect(ldif=1) handler(dn, new, listener_old, operation) + if os.path.exists(LDIF_FILE): + with open(LDIF_FILE, 'r') as fd: + ud.debug(ud.LISTENER, ud.ERROR, 'ldif:\n%s' % fd.read()) def log_ldap(severity, msg, ex, dn=None):