|
664 |
|
664 |
|
665 |
self.open_s4() |
665 |
self.open_s4() |
666 |
|
666 |
|
667 |
if not self.config.has_section('S4'): |
667 |
for section in ['S4', 'S4 rejected', 'S4 rejected timestamp', 'S4 GUID' ]: |
668 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section 'S4'") |
668 |
if not self.config.has_section(section): |
669 |
self.config.add_section('S4') |
669 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section %s" % section) |
|
|
670 |
self.config.add_section(section) |
670 |
|
671 |
|
671 |
if not self.config.has_section('S4 rejected'): |
|
|
672 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section 'S4 rejected'") |
673 |
self.config.add_section('S4 rejected') |
674 |
|
675 |
if not self.config.has_option('S4','lastUSN'): |
672 |
if not self.config.has_option('S4','lastUSN'): |
676 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init lastUSN with 0") |
673 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init lastUSN with 0") |
677 |
self._set_config_option('S4','lastUSN','0') |
674 |
self._set_config_option('S4','lastUSN','0') |
|
679 |
else: |
676 |
else: |
680 |
self.__lastUSN=int(self._get_config_option('S4','lastUSN')) |
677 |
self.__lastUSN=int(self._get_config_option('S4','lastUSN')) |
681 |
|
678 |
|
682 |
if not self.config.has_section('S4 GUID'): |
|
|
683 |
ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section 'S4 GUID'") |
684 |
self.config.add_section('S4 GUID') |
685 |
try: |
679 |
try: |
686 |
# LDAP_SERVER_SHOW_DELETED_OID -> 1.2.840.113556.1.4.417 |
680 |
# LDAP_SERVER_SHOW_DELETED_OID -> 1.2.840.113556.1.4.417 |
687 |
self.ctrl_show_deleted = LDAPControl('1.2.840.113556.1.4.417',criticality=1) |
681 |
self.ctrl_show_deleted = LDAPControl('1.2.840.113556.1.4.417',criticality=1) |
|
824 |
_d=ud.function('ldap._save_rejected') |
818 |
_d=ud.function('ldap._save_rejected') |
825 |
try: |
819 |
try: |
826 |
self._set_config_option('S4 rejected',str(id),compatible_modstring(dn)) |
820 |
self._set_config_option('S4 rejected',str(id),compatible_modstring(dn)) |
|
|
821 |
if not self._get_config_option('S4 rejected timestamp', compatible_modstring(dn.lower())): |
822 |
self._set_config_option('S4 rejected timestamp', compatible_modstring(dn.lower()), time.time()) |
827 |
except UnicodeEncodeError, msg: |
823 |
except UnicodeEncodeError, msg: |
828 |
self._set_config_option('S4 rejected',str(id),'unknown') |
824 |
self._set_config_option('S4 rejected',str(id),'unknown') |
829 |
self._debug_traceback(ud.WARN, |
825 |
self._debug_traceback(ud.WARN, |
|
835 |
|
831 |
|
836 |
def _remove_rejected(self,id): |
832 |
def _remove_rejected(self,id): |
837 |
_d=ud.function('ldap._remove_rejected') |
833 |
_d=ud.function('ldap._remove_rejected') |
|
|
834 |
dn = self._get_rejected(str(id)) |
838 |
self._remove_config_option('S4 rejected',str(id)) |
835 |
self._remove_config_option('S4 rejected',str(id)) |
839 |
|
836 |
|
|
|
837 |
# Remove the timestamp entry for this rejected DN if this is the last |
838 |
# rejected object with this DN |
839 |
if dn: |
840 |
found = False |
841 |
for f, d in self.list_rejected(): |
842 |
if d.lower() == dn.lower(): |
843 |
found = True |
844 |
break |
845 |
if not found: |
846 |
self._remove_config_option('S4 rejected timestamp',dn.lower()) |
847 |
|
848 |
def _get_rejected_timestamp(self, dn): |
849 |
return self._get_config_option('S4 rejected timestamp',dn.lower()) |
850 |
|
840 |
def _list_rejected(self): |
851 |
def _list_rejected(self): |
841 |
_d=ud.function('ldap._list_rejected') |
852 |
_d=ud.function('ldap._list_rejected') |
842 |
result = [] |
853 |
result = [] |
|
2081 |
return True |
2092 |
return True |
2082 |
|
2093 |
|
2083 |
pre_mapped_ucs_old_dn = old_dn |
2094 |
pre_mapped_ucs_old_dn = old_dn |
2084 |
|
2095 |
|
|
|
2096 |
## Is the object rejected in S4? |
2097 |
# If sync_mode is not sync, it does not matter |
2098 |
if self.property[property_type].sync_mode == 'sync': |
2099 |
t_s4 = self._get_rejected_timestamp(pre_mapped_ucs_dn.lower()) |
2100 |
t_ucs = self._get_rejected_timestamp_ucs(object['dn'].lower()) |
2101 |
if t_s4: |
2102 |
ud.debug(ud.LDAP, ud.PROCESS, 't_s4=%s'% float(t_s4)) |
2103 |
if t_ucs: |
2104 |
ud.debug(ud.LDAP, ud.PROCESS, 't_ucs=%s'% float(t_ucs)) |
2105 |
|
2106 |
if t_s4: |
2107 |
# We have a rejected UCS object, so check the timestamp |
2108 |
if not t_ucs or float(t_s4) < float(t_ucs): |
2109 |
if t_ucs: |
2110 |
ud.debug(ud.LDAP, ud.PROCESS, 'This object is already rejected in the different direction (S4 to UCS). This direction (UCS to S4) will now also rejected until the firsrst rejection is solved.') |
2111 |
# The UCS object is older, this object must be synced first |
2112 |
return False |
2113 |
|
2085 |
if old_dn: |
2114 |
if old_dn: |
2086 |
ud.debug(ud.LDAP, ud.INFO, "move %s from [%s] to [%s]" % (property_type, old_dn, object['dn'])) |
2115 |
ud.debug(ud.LDAP, ud.INFO, "move %s from [%s] to [%s]" % (property_type, old_dn, object['dn'])) |
2087 |
if hasattr ( self.property[property_type], 'dn_mapping_function' ): |
2116 |
if hasattr ( self.property[property_type], 'dn_mapping_function' ): |
|
2272 |
modlist.append((ldap.MOD_DELETE, yank_empty_attr, None)) |
2301 |
modlist.append((ldap.MOD_DELETE, yank_empty_attr, None)) |
2273 |
|
2302 |
|
2274 |
if modlist: |
2303 |
if modlist: |
2275 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: modlist: %s" % modlist) |
2304 |
ud.debug(ud.LDAP, ud.PROCESS, "sync_from_ucs: modlist: %s" % modlist) |
2276 |
self.lo_s4.lo.modify_ext_s(compatible_modstring(object['dn']), compatible_modlist(modlist), serverctrls=self.serverctrls_for_add_and_modify) |
2305 |
self.lo_s4.lo.modify_ext_s(compatible_modstring(object['dn']), compatible_modlist(modlist), serverctrls=self.serverctrls_for_add_and_modify) |
2277 |
|
2306 |
|
2278 |
|
2307 |
|