View | Details | Raw Unified | Return to bug 26515
Collapse All | Expand All

(-)modules/univention/s4connector/s4/__init__.py (-12 / +41 lines)
 Lines 664-677    Link Here 
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')
 Lines 679-687    Link Here 
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)
 Lines 824-829    Link Here 
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,
 Lines 835-842    Link Here 
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 = []
 Lines 2081-2087    Link Here 
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' ):
 Lines 2272-2278    Link Here 
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
(-)modules/univention/s4connector/__init__.py (-2 / +37 lines)
 Lines 409-417    Link Here 
409
		
409
		
410
		self.open_ucs()
410
		self.open_ucs()
411
411
412
		for section in ['DN Mapping UCS','DN Mapping CON','UCS rejected']:
412
		for section in ['DN Mapping UCS', 'DN Mapping CON', 'UCS rejected', 'UCS rejected timestamp']:
413
			if not self.config.has_section(section):
413
			if not self.config.has_section(section):
414
				self.config.add_section(section)				
414
				self.config.add_section(section)
415
415
416
		ud.debug(ud.LDAP, ud.INFO, "init finished")
416
		ud.debug(ud.LDAP, ud.INFO, "init finished")
417
417
 Lines 488-493    Link Here 
488
	def _save_rejected_ucs(self, filename, dn):
488
	def _save_rejected_ucs(self, filename, dn):
489
		_d=ud.function('ldap._save_rejected_ucs')
489
		_d=ud.function('ldap._save_rejected_ucs')
490
		self._set_config_option('UCS rejected',filename,dn)
490
		self._set_config_option('UCS rejected',filename,dn)
491
		if not self._get_config_option('UCS rejected timestamp', dn.lower()):
492
			self._set_config_option('UCS rejected timestamp', dn.lower(), time.time())
491
493
492
	def _get_rejected_ucs(self, filename):
494
	def _get_rejected_ucs(self, filename):
493
		_d=ud.function('ldap._get_rejected_ucs')
495
		_d=ud.function('ldap._get_rejected_ucs')
 Lines 495-502    Link Here 
495
497
496
	def _remove_rejected_ucs(self,filename):
498
	def _remove_rejected_ucs(self,filename):
497
		_d=ud.function('ldap._remove_rejected_ucs')
499
		_d=ud.function('ldap._remove_rejected_ucs')
500
		dn = self._get_rejected_ucs(filename)
498
		self._remove_config_option('UCS rejected',filename)
501
		self._remove_config_option('UCS rejected',filename)
499
502
503
		# Remove the timestamp entry for this rejected DN if this is the last
504
		# rejected object with this DN
505
		if dn:
506
			found = False
507
			for f, d in self.list_rejected_ucs():
508
				if d.lower() == dn.lower():
509
					found = True
510
					break
511
			if not found:
512
				self._remove_config_option('UCS rejected timestamp',dn.lower())
513
500
	def _list_rejected_ucs(self):
514
	def _list_rejected_ucs(self):
501
		_d=ud.function('ldap._list_rejected_ucs')
515
		_d=ud.function('ldap._list_rejected_ucs')
502
		result = []
516
		result = []
 Lines 513-518    Link Here 
513
527
514
	def list_rejected_ucs(self):
528
	def list_rejected_ucs(self):
515
		return self._get_config_items('UCS rejected')
529
		return self._get_config_items('UCS rejected')
530
531
	def _get_rejected_timestamp_ucs(self, dn):
532
		return self._get_config_option('UCS rejected timestamp',dn.lower())
516
		
533
		
517
	def _encode_dn_as_config_option(self, dn):
534
	def _encode_dn_as_config_option(self, dn):
518
		return dn
535
		return dn
 Lines 1243-1248    Link Here 
1243
			ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs ignored, sync_mode is %s" % self.property[property_type].sync_mode)
1260
			ud.debug(ud.LDAP, ud.INFO, "sync_to_ucs ignored, sync_mode is %s" % self.property[property_type].sync_mode)
1244
			return True
1261
			return True
1245
1262
1263
		## Is the object rejected in UCS?
1264
		# If sync_mode is not sync, it does not matter 
1265
		if self.property[property_type].sync_mode == 'sync':
1266
			t_s4 = self._get_rejected_timestamp(premapped_s4_dn.lower())
1267
			t_ucs = self._get_rejected_timestamp_ucs(object['dn'].lower())
1268
			if t_s4:
1269
				ud.debug(ud.LDAP, ud.PROCESS, 't_s4=%s'% float(t_s4))
1270
			if t_ucs:
1271
				ud.debug(ud.LDAP, ud.PROCESS, 't_ucs=%s'% float(t_ucs))
1272
1273
			if t_ucs:
1274
				# We have a rejected UCS object, so check the timestamp
1275
				if not t_s4 or float(t_ucs) < float(t_s4):
1276
					if t_s4:
1277
						ud.debug(ud.LDAP, ud.PROCESS, 'This object is already rejected in the different direction (UCS to S4 LDAP). This direction (S4 to UCS) will now also rejected until the first rejection will solved.')
1278
					# The UCS object is older, this object must be synced first
1279
					return False
1280
1246
		if object.has_key('olddn'):
1281
		if object.has_key('olddn'):
1247
			old_object = self.get_ucs_object(property_type,object['olddn'])
1282
			old_object = self.get_ucs_object(property_type,object['olddn'])
1248
		else:
1283
		else:

Return to bug 26515