View | Details | Raw Unified | Return to bug 34184 | Differences between
and this patch

Collapse All | Expand All

(-)conffiles/etc/univention/s4connector/s4/mapping.py (-15 / +31 lines)
 Lines 59-64    Link Here 
59
			'CN=DomainUpdates,CN=System,@%@connector/s4/ldap/base@%@',
59
			'CN=DomainUpdates,CN=System,@%@connector/s4/ldap/base@%@',
60
			'CN=Password Settings Container,CN=System,@%@connector/s4/ldap/base@%@',
60
			'CN=Password Settings Container,CN=System,@%@connector/s4/ldap/base@%@',
61
			'DC=RootDNSServers,CN=MicrosoftDNS,CN=System,@%@connector/s4/ldap/base@%@',
61
			'DC=RootDNSServers,CN=MicrosoftDNS,CN=System,@%@connector/s4/ldap/base@%@',
62
			'DC=RootDNSServers,CN=MicrosoftDNS,DC=DomainDnsZones,@%@connector/s4/ldap/base@%@',
63
			'DC=RootDNSServers,CN=MicrosoftDNS,DC=ForestDnsZones,@%@connector/s4/ldap/base@%@',
62
			'CN=File Replication Service,CN=System,@%@connector/s4/ldap/base@%@',
64
			'CN=File Replication Service,CN=System,@%@connector/s4/ldap/base@%@',
63
			'CN=RpcServices,CN=System,@%@connector/s4/ldap/base@%@',
65
			'CN=RpcServices,CN=System,@%@connector/s4/ldap/base@%@',
64
			'CN=Meetings,CN=System,@%@connector/s4/ldap/base@%@',
66
			'CN=Meetings,CN=System,@%@connector/s4/ldap/base@%@',
 Lines 600-641    Link Here 
600
				},
602
				},
601
603
602
		),
604
		),
605
@!@
606
607
sync_mode_dns = configRegistry.get('connector/s4/mapping/dns/syncmode')
608
if not sync_mode_dns:
609
	sync_mode_dns = configRegistry.get('connector/s4/mapping/syncmode')
610
611
if configRegistry.get('connector/s4/mapping/dns/position') == 'legacy':
612
	s4_dns_ldap_base = "CN=System,%s" % (configRegistry['connector/s4/ldap/base'],)
613
else:
614
	s4_dns_ldap_base = "DC=DomainDnsZones,%s" % (configRegistry['connector/s4/ldap/base'],)
615
616
dns_section = '''
603
	'dns': univention.s4connector.property (
617
	'dns': univention.s4connector.property (
604
			ucs_default_dn='cn=dns,@%@ldap/base@%@',
618
			ucs_default_dn='cn=dns,%(ldap_base)s',
605
			con_default_dn='CN=MicrosoftDNS,CN=System,@%@connector/s4/ldap/base@%@',
619
			con_default_dn='CN=MicrosoftDNS,%(s4_dns_ldap_base)s',
606
			ucs_module='dns/dns',
620
			ucs_module='dns/dns',
607
			
621
			
608
			identify=univention.s4connector.s4.dns.identify,
622
			identify=univention.s4connector.s4.dns.identify,
623
			sync_mode='%(sync_mode_dns)s',
609
624
610
			@!@
611
if configRegistry.get('connector/s4/mapping/dns/syncmode'):
612
	print "sync_mode='%s'," % configRegistry.get('connector/s4/mapping/dns/syncmode')
613
else:
614
	print "sync_mode='%s'," % configRegistry.get('connector/s4/mapping/syncmode')
615
@!@
616
617
			scope='sub',
625
			scope='sub',
618
626
619
			con_search_filter='(|(objectClass=dnsNode)(objectClass=dnsZone))',
627
			con_search_filter='(|(objectClass=dnsNode)(objectClass=dnsZone))',
620
628
621
			position_mapping = [( ',cn=dns,@%@ldap/base@%@', ',CN=MicrosoftDNS,CN=System,@%@connector/s4/ldap/base@%@' )],
629
			dn_mapping_function=[ univention.s4connector.s4.dns.dns_dn_mapping ],
630
''' % {
631
	'ldap_base': configRegistry['ldap/base'],
632
	'sync_mode_dns': sync_mode_dns,
633
	's4_dns_ldap_base': s4_dns_ldap_base,
634
	}
622
635
623
@!@
624
ignore_filter = ''
636
ignore_filter = ''
625
for dns in configRegistry.get('connector/s4/mapping/dns/ignorelist', '').split(','):
637
for dns in configRegistry.get('connector/s4/mapping/dns/ignorelist', '').split(','):
626
	if dns:
638
	if dns:
627
		ignore_filter += '(%s)' % (dns)
639
		ignore_filter += '(%s)' % (dns)
628
if ignore_filter:
640
if ignore_filter:
629
	print "			ignore_filter='(|%s)'," % ignore_filter
641
	dns_section = dns_section + '''
630
@!@
642
			ignore_filter='(|%s)',''' % ignore_filter
631
643
644
	dns_section = dns_section + '''
632
			ignore_subtree = global_ignore_subtree,
645
			ignore_subtree = global_ignore_subtree,
633
			
646
			
634
			con_sync_function = univention.s4connector.s4.dns.ucs2con,
647
			con_sync_function = univention.s4connector.s4.dns.ucs2con,
635
			ucs_sync_function = univention.s4connector.s4.dns.con2ucs,
648
			ucs_sync_function = univention.s4connector.s4.dns.con2ucs,
636
649
637
		),
650
		),'''
638
@!@
651
652
print dns_section
653
654
639
if configRegistry.is_true('connector/s4/mapping/gpo', True):
655
if configRegistry.is_true('connector/s4/mapping/gpo', True):
640
	ignore_filter = ''
656
	ignore_filter = ''
641
	for gpo in configRegistry.get('connector/s4/mapping/gpo/ignorelist', '').split(','):
657
	for gpo in configRegistry.get('connector/s4/mapping/gpo/ignorelist', '').split(','):
(-)debian/univention-s4-connector.postinst (+4 lines)
 Lines 134-139    Link Here 
134
		fi
134
		fi
135
	fi
135
	fi
136
136
137
	if [ "$1" = "configure" -a -n "$2" ] && dpkg --compare-versions "$2" lt 9.0.16-11; then
138
		univention-config-registry set connector/s4/mapping/dns/position?'legacy'
139
	fi
140
137
	if [ "$skip_final_restart" != "true" ]; then
141
	if [ "$skip_final_restart" != "true" ]; then
138
		/etc/init.d/univention-s4-connector restart
142
		/etc/init.d/univention-s4-connector restart
139
	fi
143
	fi
(-)debian/univention-s4-connector.univention-config-registry-variables (+6 lines)
 Lines 267-269    Link Here 
267
Description[en]=Group policies are stored in Group Policy Objects (GPOs) in the directory /var/lib/samba/sysvol/ on all Samba 4 domain controllers. The GPOs and the corresponding access rights are referenced in Samba 4 LDAP. If this option is activated, the access rights of the GPO references are synchronised to the UCS LDAP along with the references. If the variable is unset, the references are not synchronised.
267
Description[en]=Group policies are stored in Group Policy Objects (GPOs) in the directory /var/lib/samba/sysvol/ on all Samba 4 domain controllers. The GPOs and the corresponding access rights are referenced in Samba 4 LDAP. If this option is activated, the access rights of the GPO references are synchronised to the UCS LDAP along with the references. If the variable is unset, the references are not synchronised.
268
Type=bool
268
Type=bool
269
Categories=service-s4con
269
Categories=service-s4con
270
271
[connector/s4/mapping/dns/position]
272
Description[de]=Diese Variable bestimmt die Basis-DN der DNS Objekte im Samba Verzeichnisdienst. Falls sie auf dem Wert 'legacy' steht, dann schreibt der S4-Connector neue DNS-Zonen in Samba4 unter CN=System statt unter DC=DomainDnsZones. Diese Variable sollte nur einmalig nach manueller Migration der DNS-Objekte angepasst werden, falls sie noch auf 'legacy' steht.
273
Description[en]=This variable determins the base DN of DNS objects in the Samba directory service. When set to 'legacy', the S4 Connector writes new DNS zones in Samba4 below CN=System instead of below DC=DomainDnsZones. This variable should only be modified once after manual migration of the DNS objects, if it still has the value 'legacy'.
274
Type=str
275
Categories=service-s4con
(-)modules/univention/s4connector/__init__.py (+20 lines)
 Lines 825-830    Link Here 
825
			ud.debug(ud.LDAP, ud.INFO, "__sync_file_from_ucs: No mapping was found for dn: %s" % dn)
825
			ud.debug(ud.LDAP, ud.INFO, "__sync_file_from_ucs: No mapping was found for dn: %s" % dn)
826
			return True
826
			return True
827
827
828
	def get_ucs_ldap_object_dn(self, dn):
829
		_d=ud.function('ldap.get_ucs_ldap_object_dn')
830
831
		for i in [0, 1]: # do it twice if the LDAP connection was closed
832
			if type(dn) == type(u''):
833
				searchdn = dn
834
			else:
835
				searchdn = unicode(dn)
836
			try:			
837
				return self.lo.lo.lo.search_s( searchdn, ldap.SCOPE_BASE, '(objectClass=*)', ('dn',))[0][0]
838
			except ldap.NO_SUCH_OBJECT:
839
				return None
840
			except ldap.INVALID_DN_SYNTAX:
841
				return None
842
			except ldap.INVALID_SYNTAX:
843
				return None
844
			except (ldap.SERVER_DOWN, SystemExit):
845
				self.open_ucs()
846
				continue
847
828
	def get_ucs_ldap_object(self, dn):
848
	def get_ucs_ldap_object(self, dn):
829
		_d=ud.function('ldap.get_ucs_ldap_object')
849
		_d=ud.function('ldap.get_ucs_ldap_object')
830
850
(-)modules/univention/s4connector/s4/__init__.py (-17 / +54 lines)
 Lines 38-44    Link Here 
38
import univention.s4connector
38
import univention.s4connector
39
import univention.debug2 as ud
39
import univention.debug2 as ud
40
from ldap.controls import LDAPControl
40
from ldap.controls import LDAPControl
41
from ldap.controls import SimplePagedResultsControl
41
from ldap.controls import SimplePagedResultsControl, LDAPControl
42
from samba.dcerpc import security
42
from samba.dcerpc import security
43
from samba.ndr import ndr_pack, ndr_unpack
43
from samba.ndr import ndr_pack, ndr_unpack
44
from samba.dcerpc import misc
44
from samba.dcerpc import misc
 Lines 45-50    Link Here 
45
45
46
DECODE_IGNORELIST=['objectSid', 'objectGUID', 'repsFrom', 'replUpToDateVector', 'ipsecData', 'logonHours', 'userCertificate', 'dNSProperty', 'dnsRecord']
46
DECODE_IGNORELIST=['objectSid', 'objectGUID', 'repsFrom', 'replUpToDateVector', 'ipsecData', 'logonHours', 'userCertificate', 'dNSProperty', 'dnsRecord']
47
47
48
LDAP_SERVER_SHOW_DELETED_OID = "1.2.840.113556.1.4.417"
49
LDB_CONTROL_DOMAIN_SCOPE_OID = "1.2.840.113556.1.4.1339"
50
LDB_CONTROL_RELAX_OID = "1.3.6.1.4.1.4203.666.5.12"
51
LDB_CONTROL_PROVISION_OID = '1.3.6.1.4.1.7165.4.3.16'
52
48
# page results
53
# page results
49
PAGE_SIZE = 1000
54
PAGE_SIZE = 1000
50
55
 Lines 110-116    Link Here 
110
115
111
		ud.debug(ud.LDAP, ud.INFO, 'add_primary_group_to_addlist: Set primary group to %s (rid) for %s' % (primary_group_rid, object.get('dn')))
116
		ud.debug(ud.LDAP, ud.INFO, 'add_primary_group_to_addlist: Set primary group to %s (rid) for %s' % (primary_group_rid, object.get('dn')))
112
		addlist.append(('primaryGroupID', [primary_group_rid]))
117
		addlist.append(('primaryGroupID', [primary_group_rid]))
113
		LDB_CONTROL_RELAX_OID = '1.3.6.1.4.1.4203.666.5.12'
114
		serverctrls.append(LDAPControl(LDB_CONTROL_RELAX_OID,criticality=0))
118
		serverctrls.append(LDAPControl(LDB_CONTROL_RELAX_OID,criticality=0))
115
119
116
def __is_groupType_local(groupType):
120
def __is_groupType_local(groupType):
 Lines 126-132    Link Here 
126
130
127
	ud.debug(ud.LDAP, ud.INFO, "groupType: %s" % groupType)
131
	ud.debug(ud.LDAP, ud.INFO, "groupType: %s" % groupType)
128
	if __is_groupType_local(groupType):
132
	if __is_groupType_local(groupType):
129
		LDB_CONTROL_RELAX_OID = '1.3.6.1.4.1.4203.666.5.12'
130
		serverctrls.append(LDAPControl(LDB_CONTROL_RELAX_OID,criticality=0))
133
		serverctrls.append(LDAPControl(LDB_CONTROL_RELAX_OID,criticality=0))
131
134
132
		sambaSID = object.get('attributes', {}).get('sambaSID', [])[0]
135
		sambaSID = object.get('attributes', {}).get('sambaSID', [])[0]
 Lines 266-272    Link Here 
266
						try:
269
						try:
267
							if value.lower() == ucsval.lower():
270
							if value.lower() == ucsval.lower():
268
								value = conval
271
								value = conval
269
								ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: map samaccountanme regarding to mapping-table")
272
								ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: map samaccountanme according to mapping-table")
270
								continue
273
								continue
271
						except UnicodeDecodeError:
274
						except UnicodeDecodeError:
272
							pass # values are not the same codec
275
							pass # values are not the same codec
 Lines 316-322    Link Here 
316
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
319
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
317
						if samaccountname.lower() == conval.lower():
320
						if samaccountname.lower() == conval.lower():
318
							samaccountname = ucsval
321
							samaccountname = ucsval
319
							ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: map samaccountanme regarding to mapping-table")
322
							ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: map samaccountanme according to mapping-table")
320
							continue
323
							continue
321
						else:
324
						else:
322
							ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: samaccountname not in mapping-table")
325
							ud.debug(ud.LDAP, ud.INFO, "samaccount_dn_mapping: samaccountname not in mapping-table")
 Lines 384-391    Link Here 
384
def old_user_dn_mapping(s4connector, given_object):
387
def old_user_dn_mapping(s4connector, given_object):
385
	object = copy.deepcopy(given_object)
388
	object = copy.deepcopy(given_object)
386
389
387
	# LDAP_SERVER_SHOW_DELETED_OID -> 1.2.840.113556.1.4.417
390
	ctrls = [LDAPControl(LDAP_SERVER_SHOW_DELETED_OID, criticality=1)]
388
	ctrls = [LDAPControl('1.2.840.113556.1.4.417',criticality=1)]
389
	samaccountname = ''
391
	samaccountname = ''
390
392
391
	if object.has_key('sAMAccountName'):
393
	if object.has_key('sAMAccountName'):
 Lines 753-760    Link Here 
753
			ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section 'S4 GUID'")
755
			ud.debug(ud.LDAP, ud.INFO,"__init__: init add config section 'S4 GUID'")
754
			self.config.add_section('S4 GUID')
756
			self.config.add_section('S4 GUID')
755
		try:
757
		try:
756
			# LDAP_SERVER_SHOW_DELETED_OID -> 1.2.840.113556.1.4.417
758
			self.ctrl_show_deleted = LDAPControl(LDAP_SERVER_SHOW_DELETED_OID, criticality=1)
757
			self.ctrl_show_deleted = LDAPControl('1.2.840.113556.1.4.417',criticality=1)
758
			res = self.lo_s4.lo.search_ext_s('',ldap.SCOPE_BASE, 'objectclass=*',[],
759
			res = self.lo_s4.lo.search_ext_s('',ldap.SCOPE_BASE, 'objectclass=*',[],
759
								serverctrls=[ self.ctrl_show_deleted ],
760
								serverctrls=[ self.ctrl_show_deleted ],
760
								timeout=-1, sizelimit=0)
761
								timeout=-1, sizelimit=0)
 Lines 773-779    Link Here 
773
774
774
		# objectSid modification for an Samba4 object is only possible with the "provision" control:
775
		# objectSid modification for an Samba4 object is only possible with the "provision" control:
775
		if self.configRegistry.is_true('connector/s4/mapping/sid_to_s4', False):
776
		if self.configRegistry.is_true('connector/s4/mapping/sid_to_s4', False):
776
			LDB_CONTROL_PROVISION_OID = '1.3.6.1.4.1.7165.4.3.16'
777
			self.serverctrls_for_add_and_modify.append(LDAPControl(LDB_CONTROL_PROVISION_OID,criticality=0) )
777
			self.serverctrls_for_add_and_modify.append(LDAPControl(LDB_CONTROL_PROVISION_OID,criticality=0) )
778
778
779
		# Save a list of objects just created, this is needed to
779
		# Save a list of objects just created, this is needed to
 Lines 865-870    Link Here 
865
865
866
		self.lo_s4.lo.set_option(ldap.OPT_REFERRALS,0)
866
		self.lo_s4.lo.set_option(ldap.OPT_REFERRALS,0)
867
867
868
		if self.configRegistry.get('connector/s4/mapping/dns/position') == 'legacy':
869
			self.s4_ldap_partitions = (self.s4_ldap_base,)
870
		else:
871
			self.s4_ldap_partitions = (self.s4_ldap_base, "DC=DomainDnsZones,%s" % self.s4_ldap_base, "DC=ForestDnsZones,%s" % self.s4_ldap_base)
872
873
868
	# encode string to unicode
874
	# encode string to unicode
869
	def encode(self, string):
875
	def encode(self, string):
870
		try:
876
		try:
 Lines 968-973    Link Here 
968
	def isInCreationList(self, dn):
974
	def isInCreationList(self, dn):
969
		return dn.lower() in self.creation_list
975
		return dn.lower() in self.creation_list
970
976
977
	def get_object_dn(self, dn):
978
		_d=ud.function('ldap.get_object_dn')
979
		for i in [0, 1]: # do it twice if the LDAP connection was closed
980
			try:
981
				dn, s4_object=self.lo_s4.lo.search_ext_s(compatible_modstring(dn),ldap.SCOPE_BASE,'(objectClass=*)', ('dn',))[0]
982
				try:
983
					ud.debug(ud.LDAP, ud.INFO,"get_object: got object: %s" % dn)
984
				except: # FIXME: which exception is to be caught?
985
					ud.debug(ud.LDAP, ud.INFO,"get_object: got object: <print failed>")
986
				return dn
987
			except (ldap.SERVER_DOWN, SystemExit):
988
				if i == 0:
989
					self.open_s4()
990
					continue
991
				raise
992
			except: # FIXME: which exception is to be caught?
993
				pass
994
		
971
	def get_object(self, dn):
995
	def get_object(self, dn):
972
		_d=ud.function('ldap.get_object')
996
		_d=ud.function('ldap.get_object')
973
		for i in [0, 1]: # do it twice if the LDAP connection was closed
997
		for i in [0, 1]: # do it twice if the LDAP connection was closed
 Lines 1003-1008    Link Here 
1003
1027
1004
		return max(usnchanged,usncreated)
1028
		return max(usnchanged,usncreated)
1005
1029
1030
	def __search_s4_partitions(self, scope=ldap.SCOPE_SUBTREE, filter='', attrlist= [], show_deleted=False):
1031
		'''
1032
		search s4 across all partitions listed in self.s4_ldap_partitions
1033
		'''
1034
		_d=ud.function('ldap.__search_s4_partitions')
1035
		res = []
1036
		for base in self.s4_ldap_partitions:
1037
			res += self.__search_s4(base, scope, filter, attrlist, show_deleted)
1038
1039
		return res
1040
1006
	def __search_s4(self, base=None, scope=ldap.SCOPE_SUBTREE, filter='', attrlist= [], show_deleted=False):
1041
	def __search_s4(self, base=None, scope=ldap.SCOPE_SUBTREE, filter='', attrlist= [], show_deleted=False):
1007
		'''
1042
		'''
1008
		search s4
1043
		search s4
 Lines 1012-1023    Link Here 
1012
		if not base:
1047
		if not base:
1013
			base=self.lo_s4.base
1048
			base=self.lo_s4.base
1014
1049
1015
		ctrls=[]
1050
		ctrls=[
1016
		ctrls.append(SimplePagedResultsControl(True, PAGE_SIZE, ''))
1051
			LDAPControl(LDB_CONTROL_DOMAIN_SCOPE_OID, criticality=0),	## Don't show referrals
1052
			SimplePagedResultsControl(True, PAGE_SIZE, ''),
1053
		]
1017
1054
1018
		if show_deleted:
1055
		if show_deleted:
1019
			# LDAP_SERVER_SHOW_DELETED_OID -> 1.2.840.113556.1.4.417
1056
			ctrls.append(LDAPControl(LDAP_SERVER_SHOW_DELETED_OID, criticality=1))
1020
			ctrls.append(LDAPControl('1.2.840.113556.1.4.417',criticality=1))
1021
1057
1022
		ud.debug(ud.LDAP, ud.INFO, "Search S4 with filter: %s" % filter)
1058
		ud.debug(ud.LDAP, ud.INFO, "Search S4 with filter: %s" % filter)
1023
		msgid = self.lo_s4.lo.search_ext(base, scope, filter, attrlist, serverctrls=ctrls, timeout=-1, sizelimit=0)
1059
		msgid = self.lo_s4.lo.search_ext(base, scope, filter, attrlist, serverctrls=ctrls, timeout=-1, sizelimit=0)
 Lines 1046-1052    Link Here 
1046
			else:
1082
			else:
1047
				ud.debug(ud.LDAP, ud.WARN, "S4 ignores PAGE_RESULTS")
1083
				ud.debug(ud.LDAP, ud.WARN, "S4 ignores PAGE_RESULTS")
1048
				break
1084
				break
1049
1050
		
1085
		
1051
		return encode_s4_resultlist(res)
1086
		return encode_s4_resultlist(res)
1052
		
1087
		
 Lines 1078-1084    Link Here 
1078
			if filter !='':
1113
			if filter !='':
1079
				usnFilter = '(&(%s)(%s))' % ( filter, usnFilter )
1114
				usnFilter = '(&(%s)(%s))' % ( filter, usnFilter )
1080
				
1115
				
1081
			return self.__search_s4( filter=usnFilter, show_deleted=show_deleted)
1116
			res = self.__search_s4_partitions(filter=usnFilter, show_deleted=show_deleted)
1117
			return sorted(res, key=lambda element: element[1][attribute][0])
1082
1118
1083
1119
1084
		# search fpr objects with uSNCreated and uSNChanged in the known range
1120
		# search fpr objects with uSNCreated and uSNChanged in the known range
 Lines 1132-1140    Link Here 
1132
			filter = '(&(%s)(|(uSNChanged=%s)(uSNCreated=%s)))' % (filter,changeUSN,changeUSN)
1168
			filter = '(&(%s)(|(uSNChanged=%s)(uSNCreated=%s)))' % (filter,changeUSN,changeUSN)
1133
		else:
1169
		else:
1134
			filter = '(|(uSNChanged=%s)(uSNCreated=%s))' % (changeUSN,changeUSN)
1170
			filter = '(|(uSNChanged=%s)(uSNCreated=%s))' % (changeUSN,changeUSN)
1135
		return self.__search_s4(filter=filter, show_deleted=show_deleted)
1136
1171
1172
		return self.__search_s4_partitions(filter=filter, show_deleted=show_deleted)
1137
1173
1174
1138
	def __dn_from_deleted_object(self, object, GUID):
1175
	def __dn_from_deleted_object(self, object, GUID):
1139
		'''
1176
		'''
1140
		gets dn for deleted object (original dn before the object was moved into the deleted objects container)
1177
		gets dn for deleted object (original dn before the object was moved into the deleted objects container)
(-)modules/univention/s4connector/s4/dns.py (-37 / +284 lines)
 Lines 35-47    Link Here 
35
import univention.debug2 as ud
35
import univention.debug2 as ud
36
import univention.s4connector.s4
36
import univention.s4connector.s4
37
import univention.admin.uldap
37
import univention.admin.uldap
38
                                                                                                                                                                                                   
39
from samba.dcerpc import dnsp                                                                                                                                                                      
40
from samba.ndr import ndr_print                                                                                                                                                                    
41
from samba.ndr import ndr_pack
42
from samba.ndr import ndr_unpack                                                                                                                                                                   
43
import binascii                                                                                                                                                                                    
44
38
39
from samba.dcerpc import dnsp
40
from samba.ndr import ndr_print, ndr_pack, ndr_unpack
41
import binascii
42
import copy
43
import time
44
45
from samba.provision.sambadns import ARecord
45
from samba.provision.sambadns import ARecord
46
# def __init__(self, ip_addr, serial=1, ttl=3600):
46
# def __init__(self, ip_addr, serial=1, ttl=3600):
47
47
 Lines 90-95    Link Here 
90
import univention.admin.handlers.dns.reverse_zone
90
import univention.admin.handlers.dns.reverse_zone
91
import univention.admin.handlers.dns.ptr_record
91
import univention.admin.handlers.dns.ptr_record
92
92
93
# mapping funtions
94
def dns_dn_mapping(s4connector, given_object, dn_mapping_stored, isUCSobject):
95
	'''
96
	map dn of given object (which must have an s4_RR_attr in S4)
97
	ol_oc_filter and s4_RR_filter are objectclass filters in UCS and S4
98
	'''
99
	obj = copy.deepcopy(given_object)
100
101
	propertyname = 'dns'
102
	propertyattrib = u'relativeDomainName'	## using LDAP name here, for simplicity
103
	ol_oc_filter = '(objectClass=dNSZone)'	## all OpenLDAP DNS records match
104
	ol_RR_attr = 'relativeDomainName'
105
	s4_RR_filter = u'(objectClass=dnsNode)'	## This also matches the DC=@ SOA object
106
	s4_RR_attr = 'dc'						## Note: the S4 attribute itself is lowercase
107
108
	if obj['dn'] != None:
109
		try:
110
			s4_RR_val = obj['attributes'][s4_RR_attr][0]
111
		except (KeyError, IndexError):
112
			s4_RR_val = ''
113
	
114
	def dn_premapped(given_object, dn_key, dn_mapping_stored):
115
		if (not dn_key in dn_mapping_stored) or (not given_object[dn_key]):
116
			ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: not premapped (in first instance)")
117
			return False
118
		else: # check if DN exists
119
			if isUCSobject:
120
				premapped_dn = s4connector.get_object_dn(given_object[dn_key])
121
				if premapped_dn != None:
122
					# ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped S4 object found")
123
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped S4 object: %s" % premapped_dn)
124
					return True
125
				else:
126
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped S4 object not found")
127
					return False
128
			else:
129
				premapped_dn = s4connector.get_ucs_ldap_object_dn(given_object[dn_key])
130
				if premapped_dn != None:
131
					# ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped UCS object found")
132
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped UCS object: %s" % premapped_dn)
133
					return True
134
				else:
135
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: premapped UCS object not found")
136
					return False
137
138
	for dn_key in ['dn', 'olddn']:
139
		ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: check newdn for key '%s'" % dn_key)
140
		if dn_key in obj and not dn_premapped(obj, dn_key, dn_mapping_stored):
141
142
			dn = obj[dn_key]
143
			ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: dn: %s" % dn)
144
145
			# Skip Configuration objects with empty DNs
146
			if dn == None:
147
				break
148
149
			pos = string.find(dn,'=')
150
			rdn = univention.s4connector.s4.explode_unicode_dn(dn)
151
			pos2 = len(rdn[0])
152
153
			if isUCSobject:
154
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: got an UCS-Object")
155
				# lookup the relativeDomainName as DC/dnsNode in S4 to get corresponding DN, if not found create new
156
157
				try:
158
					relativeDomainName = obj['attributes'][ol_RR_attr][0]
159
				except (KeyError, IndexError):
160
					### Safety fallback for the unexpected case, where relativeDomainName would not be set
161
					rdn0_attrib = dn[:pos]
162
					if 'zoneName' == rdn0_attrib:
163
						relativeDomainName = '@'
164
					else:
165
						raise ## can't determine relativeDomainName
166
167
				if s4connector.property[propertyname].mapping_table and propertyattrib in s4connector.property[propertyname].mapping_table.keys():
168
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
169
						try:
170
							if relativeDomainName.lower() == ucsval.lower():
171
								relativeDomainName = conval
172
								ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: map relativeDomainName according to mapping-table")
173
								continue
174
						except UnicodeDecodeError:
175
							pass # values are not the same codec
176
				
177
				try:
178
					ol_zone_name = obj['attributes']['zoneName'][0]
179
				except (KeyError, IndexError):
180
					### Safety fallback for the unexpected case, where zoneName would not be set
181
					rdn0_attrib = dn[:pos]
182
					if ol_RR_attr == rdn0_attrib:
183
						## get parent following the recipe from __split_s4_dns_dn:
184
						rdn1_tmp = rdn[1].split('=')
185
						rdn1_key, rdn1_val = (rdn1_tmp[0], string.join(rdn1_tmp[1:], '='))
186
						if 'zoneName' == rdn1_key:
187
							ol_zone_name = rdn1_val
188
						else:
189
							raise ## can't determine zoneName for this relativeDomainName
190
191
				if '@' == relativeDomainName:	## or dn starts with 'zoneName='
192
					s4_filter = '(&(objectClass=dnsZone)(%s=%s))' % (s4_RR_attr, ol_zone_name)
193
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: search in S4 %s" % s4_filter)
194
					for base in s4connector.s4_ldap_partitions:
195
						result = s4connector._s4__search_s4(
196
								base,
197
								ldap.SCOPE_SUBTREE,
198
								univention.s4connector.s4.compatible_modstring(s4_filter),
199
								attrlist=(s4_RR_attr,),
200
								show_deleted=False)
201
202
						if result:
203
							break
204
				else:
205
					## identify position by parent zone name
206
					ol_zone_dn = s4connector.lo.parentDn(dn)
207
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: get dns_dn_mapping for %s" % ol_zone_dn)
208
					fake_ol_zone_object = {
209
						'dn': ol_zone_dn,
210
						'attributes': {
211
							'objectClass': ['top', 'dNSZone'],
212
							'relativeDomainName': ['@'],
213
							'zoneName': [ol_zone_name],
214
							},
215
						'olddn': None,	## Just fake, not used
216
						}
217
					s4_zone_object = dns_dn_mapping(s4connector, fake_ol_zone_object, dn_mapping_stored, isUCSobject)
218
					## and use its parent as the search base
219
					s4_zone_dn = s4connector.lo_s4.parentDn(s4_zone_object['dn'])
220
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: search in s4 %s=%s" % (s4_RR_attr, relativeDomainName))
221
					result = s4connector._s4__search_s4(
222
							s4_zone_dn,
223
							ldap.SCOPE_SUBTREE,
224
							univention.s4connector.s4.compatible_modstring('(&%s(%s=%s))' % (s4_RR_filter, s4_RR_attr, relativeDomainName)),
225
							attrlist=('dn',),
226
							show_deleted=False)
227
228
				try:
229
					s4dn_utf16_le = result[0][0]
230
				except (IndexError, TypeError):
231
					s4dn_utf16_le = None
232
233
				if s4dn_utf16_le: # no referral, so we've got a valid result
234
					s4dn = univention.s4connector.s4.encode_attrib(result[0][0])
235
					s4pos2 = len(univention.s4connector.s4.explode_unicode_dn(s4dn)[0])
236
					if dn_key == 'olddn' or (dn_key == 'dn' and not 'olddn' in obj):
237
						## TODO: Why do we differenciate here?
238
						newdn = s4dn
239
					else:
240
						## TODO: Why do we need to patch the DNs here? Rename case? Modify case?
241
						s4dn = s4dn[:s4pos2] + dn[pos2:]
242
						newdn = s4dn.lower().replace(s4connector.lo_s4.base.lower(), s4connector.lo.base.lower())					
243
				else:
244
					## Ok, it's a new object, so propose a S4 DN for it:
245
					if '@' == relativeDomainName:	## or dn starts with 'zoneName='
246
						new_rdn = 'dc=%s' % ol_zone_name
247
					else:
248
						new_rdn = 'dc=%s,dc=%s' % (relativeDomainName, ol_zone_name)
249
					newdn = new_rdn + ',' + s4connector.property['dns'].con_default_dn
250
251
			else:
252
				# get the object to read the s4_RR_attr in S4 and use it as name
253
				# we have no fallback here, the given dn must be found in S4 or we've got an error
254
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: got an S4-Object")
255
				i = 0
256
				
257
				while ( not s4_RR_val ): # in case of olddn this is already set
258
					i = i + 1
259
					search_dn = obj.get('deleted_dn', dn)
260
					try:
261
						s4_RR_val = univention.s4connector.s4.encode_attrib(
262
							s4connector.lo_s4.lo.search_ext_s(univention.s4connector.s4.compatible_modstring(search_dn), ldap.SCOPE_BASE,
263
											s4_RR_filter, [s4_RR_attr]) [0][1][s4_RR_attr][0])
264
						ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: got %s from S4" % s4_RR_attr)
265
					except ldap.NO_SUCH_OBJECT: # S4 may need time
266
						if i > 5:
267
							raise
268
						time.sleep(1) # S4 may need some time...
269
270
				if s4connector.property[propertyname].mapping_table and propertyattrib in s4connector.property[propertyname].mapping_table.keys():
271
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
272
						if s4_RR_val.lower() == conval.lower():
273
							s4_RR_val = ucsval
274
							ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: map %s according to mapping-table" % s4_RR_attr)
275
							continue
276
						else:
277
							ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: %s not in mapping-table" % s4_RR_attr)
278
279
				# search for object with this dn in ucs, needed if it is located in a different container
280
				try:
281
					s4_ocs = obj['attributes']['objectClass']
282
				except (KeyError, TypeError):
283
					s4_ocs = []
284
285
				if 'dnsZone' in s4_ocs:
286
					s4_zone_name = s4_RR_val
287
					base = s4connector.lo.base
288
					ol_search_attr = 'zoneName'
289
					## could use a specific LDAP filter here, but not necessary:
290
					# ol_oc_filter = '(&(objectClass=dNSZone)(|(univentionObjectType=dns/forward_zone)(univentionObjectType=dns/reverse_zone)))'
291
				elif 'dnsNode' in s4_ocs:
292
					## identify position of the parent zone
293
					s4pos = string.find(rdn[1], '=')
294
					s4_zone_name = rdn[1][s4pos+1:]
295
					s4_zone_dn = s4connector.lo_s4.parentDn(dn)
296
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: get dns_dn_mapping for %s" % s4_zone_dn)
297
					fake_s4_zone_object = {
298
						'dn': s4_zone_dn,
299
						'attributes': {
300
							'objectClass': ['top', 'dnsZone'],
301
							'dc': [s4_zone_name],
302
						},
303
						'olddn': None,	## Just fake, not used
304
						}
305
					ol_zone_object = dns_dn_mapping(s4connector, fake_s4_zone_object, dn_mapping_stored, isUCSobject)
306
					## and use that as the search base
307
					base = ol_zone_object['dn']
308
					ol_search_attr = ol_RR_attr
309
					## could use a specific LDAP filter here, but not necessary:
310
					# ol_oc_filter = '(&(objectClass=dNSZone)(!(|(univentionObjectType=dns/forward_zone)(univentionObjectType=dns/reverse_zone))))'
311
312
				ud.debug(ud.LDAP, ud.WARN, "dns_dn_mapping: UCS filter: (&%s(%s=%s))" % (ol_oc_filter, ol_search_attr, s4_RR_val))
313
				ucsdn_result = s4connector.search_ucs(filter=u'(&%s(%s=%s))' % (ol_oc_filter, ol_search_attr, s4_RR_val),
314
								   base=base, scope='sub', attr=('dn',))
315
316
				try:
317
					ucsdn = ucsdn_result[0][0]
318
				except (IndexError, TypeError):
319
					ucsdn = None
320
					
321
				ud.debug(ud.LDAP, ud.ALL, "dns_dn_mapping: Found ucsdn: %s" % ucsdn)
322
				if ucsdn:
323
					## In this case we have found the old or first known DN:
324
					newdn = ucsdn
325
					## HACK:
326
					# pos = string.find(ucsdn, '=')
327
					# newdn = ol_search_attr + ucsdn[pos:]	## adjust for zoneName
328
					ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: newdn is ucsdn")
329
				else:
330
					## Ok, it's a new object, so propose a S4 DN for it:
331
					if 'dnsZone' in s4_ocs or '@' == s4_RR_val:
332
						new_rdn = 'zoneName=%s' % s4_zone_name
333
					else:
334
						new_rdn = 'relativeDomainName=%s,zoneName=%s' % (s4_RR_val, s4_zone_name)
335
					newdn = new_rdn + ',' + s4connector.property['dns'].ucs_default_dn
336
337
			try:
338
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: mapping for key '%s':" % dn_key)
339
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: source DN: %s" % dn)
340
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: mapped DN: %s" % newdn)
341
			except: # FIXME: which exception is to be caught?
342
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: dn-print failed")
343
344
			obj[dn_key]=newdn
345
346
	return obj
347
93
''' HELPER functions '''
348
''' HELPER functions '''
94
def __append_dot(str):
349
def __append_dot(str):
95
	if str[-1] != '.':
350
	if str[-1] != '.':
 Lines 109-129    Link Here 
109
		raise 
364
		raise 
110
	return zoneName
365
	return zoneName
111
366
112
def __create_default_s4_zone_dn(s4connector, object):
367
def __create_s4_forward_zone(s4connector, zoneDn):
113
	zoneName=__get_zone_name(object)
114
	dn='DC=%s,%s' % (zoneName[0], s4connector.property['dns'].con_default_dn)
115
	return (dn, zoneName)
116
117
def __create_s4_forward_zone(s4connector, zoneDn, zoneName):
118
	al=[]
368
	al=[]
119
	al.append(('objectClass', ['top', 'dnsZone']))
369
	al.append(('objectClass', ['top', 'dnsZone']))
120
	al.append(('DC', univention.s4connector.s4.compatible_list(zoneName)))
121
370
122
	ud.debug(ud.LDAP, ud.INFO, '_dns_zone_forward_con_create: dn: %s' % zoneDn)
371
	ud.debug(ud.LDAP, ud.INFO, '_dns_zone_forward_con_create: dn: %s' % zoneDn)
123
	ud.debug(ud.LDAP, ud.INFO, '_dns_zone_forward_con_create: al: %s' % al)
372
	ud.debug(ud.LDAP, ud.INFO, '_dns_zone_forward_con_create: al: %s' % al)
124
	s4connector.lo_s4.lo.add_s(zoneDn, al)
373
	s4connector.lo_s4.lo.add_s(zoneDn, al)
125
374
126
def __create_s4_forward_zone_at(s4connector, zoneDnAt, zoneName):
375
def __create_s4_forward_zone_at(s4connector, zoneDnAt):
127
	al=[]
376
	al=[]
128
	al.append(('objectClass', ['top', 'dnsNode']))
377
	al.append(('objectClass', ['top', 'dnsNode']))
129
	al.append(('dc', ['@']))
378
	al.append(('dc', ['@']))
 Lines 295-307    Link Here 
295
def s4_zone_create(s4connector, object):
544
def s4_zone_create(s4connector, object):
296
	_d=ud.function('s4_zone_create')
545
	_d=ud.function('s4_zone_create')
297
546
298
	zoneDn, zoneName=__create_default_s4_zone_dn(s4connector, object)
547
	zoneDn = object['dn']
548
	zoneName = __get_zone_name(object)
299
		
549
		
300
	# Create the forward zone in S4 if it does not exist
550
	# Create the forward zone in S4 if it does not exist
301
	try:
551
	try:
302
		searchResult=s4connector.lo_s4.lo.search_s(zoneDn, ldap.SCOPE_BASE, '(objectClass=*)',['dn'])
552
		searchResult=s4connector.lo_s4.lo.search_s(zoneDn, ldap.SCOPE_BASE, '(objectClass=*)',['dn'])
303
	except ldap.NO_SUCH_OBJECT:
553
	except ldap.NO_SUCH_OBJECT:
304
		__create_s4_forward_zone(s4connector, zoneDn, zoneName)
554
		__create_s4_forward_zone(s4connector, zoneDn)
305
	
555
	
306
	# Create @ object
556
	# Create @ object
307
	zoneDnAt='DC=@,%s' % zoneDn
557
	zoneDnAt='DC=@,%s' % zoneDn
 Lines 313-319    Link Here 
313
		if searchResult and searchResult[0][1]:
563
		if searchResult and searchResult[0][1]:
314
			old_dnsRecords=searchResult[0][1].get('dnsRecord')
564
			old_dnsRecords=searchResult[0][1].get('dnsRecord')
315
	except ldap.NO_SUCH_OBJECT:
565
	except ldap.NO_SUCH_OBJECT:
316
		__create_s4_forward_zone_at(s4connector, zoneDnAt, zoneName)
566
		__create_s4_forward_zone_at(s4connector, zoneDnAt)
317
567
318
	dnsRecords=[]
568
	dnsRecords=[]
319
569
 Lines 354-360    Link Here 
354
def s4_zone_delete(s4connector, object):
604
def s4_zone_delete(s4connector, object):
355
	_d=ud.function('s4_zone_delete')
605
	_d=ud.function('s4_zone_delete')
356
606
357
	zoneDn, zoneName=__create_default_s4_zone_dn(s4connector, object)
607
	zoneDn = object['dn']
358
608
359
	zoneDnAt='DC=@,%s' % zoneDn
609
	zoneDnAt='DC=@,%s' % zoneDn
360
610
 Lines 373-380    Link Here 
373
def s4_dns_node_base_create(s4connector, object, dnsRecords):
623
def s4_dns_node_base_create(s4connector, object, dnsRecords):
374
	_d=ud.function('s4_dns_node_base_create')
624
	_d=ud.function('s4_dns_node_base_create')
375
625
376
	zoneDn, zoneName=__create_default_s4_zone_dn(s4connector, object)
377
378
	relativeDomainNames=object['attributes'].get('relativeDomainName')
626
	relativeDomainNames=object['attributes'].get('relativeDomainName')
379
	relativeDomainNames=univention.s4connector.s4.compatible_list(relativeDomainNames)
627
	relativeDomainNames=univention.s4connector.s4.compatible_list(relativeDomainNames)
380
	
628
	
 Lines 381-387    Link Here 
381
	old_dnsRecords=[]
629
	old_dnsRecords=[]
382
630
383
	# Create dnsNode object
631
	# Create dnsNode object
384
	dnsNodeDn='DC=%s,%s' % (relativeDomainNames[0],zoneDn)
632
	dnsNodeDn=object['dn']
385
	try:
633
	try:
386
		searchResult=s4connector.lo_s4.lo.search_s(dnsNodeDn, ldap.SCOPE_BASE, '(objectClass=*)')
634
		searchResult=s4connector.lo_s4.lo.search_s(dnsNodeDn, ldap.SCOPE_BASE, '(objectClass=*)')
387
		if searchResult and searchResult[0][1]:
635
		if searchResult and searchResult[0][1]:
 Lines 396-407    Link Here 
396
def s4_dns_node_base_delete(s4connector, object):
644
def s4_dns_node_base_delete(s4connector, object):
397
	_d=ud.function('s4_dns_node_base_delete')
645
	_d=ud.function('s4_dns_node_base_delete')
398
646
399
	zoneDn, zoneName=__create_default_s4_zone_dn(s4connector, object)
400
401
	relativeDomainNames=object['attributes'].get('relativeDomainName')
647
	relativeDomainNames=object['attributes'].get('relativeDomainName')
402
	relativeDomainNames=univention.s4connector.s4.compatible_list(relativeDomainNames)
648
	relativeDomainNames=univention.s4connector.s4.compatible_list(relativeDomainNames)
403
649
404
	dnsNodeDn='DC=%s,%s' % (relativeDomainNames[0],zoneDn)
650
	dnsNodeDn=object['dn']
405
	try:
651
	try:
406
		res=s4connector.lo_s4.lo.delete_s(dnsNodeDn)
652
		res=s4connector.lo_s4.lo.delete_s(dnsNodeDn)
407
	except ldap.NO_SUCH_OBJECT:
653
	except ldap.NO_SUCH_OBJECT:
 Lines 422-428    Link Here 
422
668
423
	return True
669
	return True
424
670
425
def __split_s4_dn(dn):
671
def __split_s4_dns_dn(dn):
426
	# split zone
672
	# split zone
427
	dn=ldap.explode_dn(dn)
673
	dn=ldap.explode_dn(dn)
428
674
 Lines 436-442    Link Here 
436
	_d=ud.function('ucs_host_record_create')
682
	_d=ud.function('ucs_host_record_create')
437
	ud.debug(ud.LDAP, ud.INFO, 'ucs_host_record_create: object: %s' % object)
683
	ud.debug(ud.LDAP, ud.INFO, 'ucs_host_record_create: object: %s' % object)
438
684
439
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
685
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
440
686
441
	# unpack the host record
687
	# unpack the host record
442
	a=__unpack_aRecord(object)
688
	a=__unpack_aRecord(object)
 Lines 472-478    Link Here 
472
	_d=ud.function('ucs_host_record_delete')
718
	_d=ud.function('ucs_host_record_delete')
473
	ud.debug(ud.LDAP, ud.INFO, 'ucs_host_record_delete: object: %s' % object)
719
	ud.debug(ud.LDAP, ud.INFO, 'ucs_host_record_delete: object: %s' % object)
474
720
475
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
721
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
476
722
477
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
723
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
478
	if len(searchResult) > 0:
724
	if len(searchResult) > 0:
 Lines 501-507    Link Here 
501
	_d=ud.function('ucs_ptr_record_create')
747
	_d=ud.function('ucs_ptr_record_create')
502
	ud.debug(ud.LDAP, ud.INFO, 'ucs_ptr_record_create: object: %s' % object)
748
	ud.debug(ud.LDAP, ud.INFO, 'ucs_ptr_record_create: object: %s' % object)
503
749
504
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
750
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
505
751
506
	# unpack the host record
752
	# unpack the host record
507
	ptr=__unpack_ptrRecord(object)
753
	ptr=__unpack_ptrRecord(object)
 Lines 536-542    Link Here 
536
	_d=ud.function('ucs_ptr_record_delete')
782
	_d=ud.function('ucs_ptr_record_delete')
537
	ud.debug(ud.LDAP, ud.INFO, 'ucs_ptr_record_delete: object: %s' % object)
783
	ud.debug(ud.LDAP, ud.INFO, 'ucs_ptr_record_delete: object: %s' % object)
538
784
539
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
785
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
540
786
541
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
787
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
542
	if len(searchResult) > 0:
788
	if len(searchResult) > 0:
 Lines 553-559    Link Here 
553
	_d=ud.function('ucs_cname_create')
799
	_d=ud.function('ucs_cname_create')
554
	ud.debug(ud.LDAP, ud.INFO, 'ucs_cname_create: object: %s' % object)
800
	ud.debug(ud.LDAP, ud.INFO, 'ucs_cname_create: object: %s' % object)
555
801
556
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
802
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
557
803
558
	# unpack the host record
804
	# unpack the host record
559
	c=__unpack_cName(object)
805
	c=__unpack_cName(object)
 Lines 588-594    Link Here 
588
	_d=ud.function('ucs_cname_delete')
834
	_d=ud.function('ucs_cname_delete')
589
	ud.debug(ud.LDAP, ud.INFO, 'ucs_cname_delete: object: %s' % object)
835
	ud.debug(ud.LDAP, ud.INFO, 'ucs_cname_delete: object: %s' % object)
590
836
591
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
837
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
592
838
593
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
839
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
594
	if len(searchResult) > 0:
840
	if len(searchResult) > 0:
 Lines 614-620    Link Here 
614
	_d=ud.function('ucs_srv_record_create')
860
	_d=ud.function('ucs_srv_record_create')
615
	ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: object: %s' % object)
861
	ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: object: %s' % object)
616
862
617
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
863
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
618
864
619
	# unpack the host record
865
	# unpack the host record
620
	srv=__unpack_sRVrecord(object)
866
	srv=__unpack_sRVrecord(object)
 Lines 673-679    Link Here 
673
	_d=ud.function('ucs_srv_record_delete')
919
	_d=ud.function('ucs_srv_record_delete')
674
	ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_delete: object: %s' % object)
920
	ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_delete: object: %s' % object)
675
921
676
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
922
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
677
923
678
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
924
	searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
679
	if len(searchResult) > 0:
925
	if len(searchResult) > 0:
 Lines 692-698    Link Here 
692
938
693
	dnsRecords=[]
939
	dnsRecords=[]
694
940
695
	zoneDn, zoneName=__create_default_s4_zone_dn(s4connector, object)
941
	zoneDn = object['dn']
942
	zoneName = __get_zone_name(object)
696
943
697
	relativeDomainName=object['attributes'].get('relativeDomainName')
944
	relativeDomainName=object['attributes'].get('relativeDomainName')
698
	relativeDomainName=univention.s4connector.s4.compatible_list(relativeDomainName)
945
	relativeDomainName=univention.s4connector.s4.compatible_list(relativeDomainName)
 Lines 727-733    Link Here 
727
def ucs_zone_create(s4connector, object, dns_type):
974
def ucs_zone_create(s4connector, object, dns_type):
728
	_d=ud.function('ucs_zone_create')
975
	_d=ud.function('ucs_zone_create')
729
976
730
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
977
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
731
978
732
	# create the zone if the dc=@ object was created
979
	# create the zone if the dc=@ object was created
733
	if relativeDomainName != '@':
980
	if relativeDomainName != '@':
 Lines 804-810    Link Here 
804
def ucs_zone_delete(s4connector, object, dns_type):
1051
def ucs_zone_delete(s4connector, object, dns_type):
805
	_d=ud.function('ucs_zone_delete')
1052
	_d=ud.function('ucs_zone_delete')
806
1053
807
	zoneName, relativeDomainName=__split_s4_dn(object['dn'])
1054
	zoneName, relativeDomainName=__split_s4_dns_dn(object['dn'])
808
1055
809
	if relativeDomainName == '@':
1056
	if relativeDomainName == '@':
810
		searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
1057
		searchResult=s4connector.lo.search(filter='(&(relativeDomainName=%s)(zoneName=%s))' % (relativeDomainName, zoneName), unique=1)
 Lines 890-896    Link Here 
890
		ud.debug(ud.LDAP, ud.INFO, 'dns ucs2con: Ignore unkown dns object: %s' % object['dn'])
1137
		ud.debug(ud.LDAP, ud.INFO, 'dns ucs2con: Ignore unkown dns object: %s' % object['dn'])
891
		return True
1138
		return True
892
1139
893
	ud.debug(ud.LDAP, ud.INFO, 'dns ucs2con: Object (%s) is from type %s' % (object['dn'], dns_type))
1140
	ud.debug(ud.LDAP, ud.INFO, 'dns ucs2con: Object (%s) is of type %s' % (object['dn'], dns_type))
894
		
1141
		
895
	if dns_type == 'forward_zone' or dns_type == 'reverse_zone':
1142
	if dns_type == 'forward_zone' or dns_type == 'reverse_zone':
896
		if object['modtype'] in ['add', 'modify']:
1143
		if object['modtype'] in ['add', 'modify']:

Return to bug 34184