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

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py (-4 / +14 lines)
 Lines 496-502   def _ldap_dn(self): Link Here 
496
		identifier = []
496
		identifier = []
497
		for name, prop in self.descriptions.items():
497
		for name, prop in self.descriptions.items():
498
			if prop.identifies:
498
			if prop.identifies:
499
				identifier.append((self.mapping.mapName(name), self.mapping.mapValue(name, self.info[name]), 2))
499
				identifier.append((self.mapping.mapName(name), self.mapping.mapValue(name, self.info[name]), ldap.AVA_BINARY))
500
		return '%s,%s' % (ldap.dn.dn2str([identifier]), self.position.getDn())
500
		return '%s,%s' % (ldap.dn.dn2str([identifier]), self.position.getDn())
501
501
502
	def _ldap_post_create(self):
502
	def _ldap_post_create(self):
 Lines 1164-1172   def open( self ): Link Here 
1164
1164
1165
		# search forward zone and insert into the object
1165
		# search forward zone and insert into the object
1166
		if self [ 'name' ]:
1166
		if self [ 'name' ]:
1167
			name = unicode(self['name']).encode('idna')
1167
			tmppos = univention.admin.uldap.position( self.position.getDomain( ) )
1168
			tmppos = univention.admin.uldap.position( self.position.getDomain( ) )
1168
1169
1169
			searchFilter = filter_format('(&(objectClass=dNSZone)(relativeDomainName=%s)(!(cNAMERecord=*)))', [self['name']])
1170
			searchFilter = filter_format('(&(objectClass=dNSZone)(relativeDomainName=%s)(!(cNAMERecord=*)))', [name,])
1170
			try:
1171
			try:
1171
				result = self.lo.search( base = tmppos.getBase( ),scope = 'domain', filter = searchFilter, attr = [ 'zoneName', 'aRecord', 'aAAARecord' ], unique = 0 )
1172
				result = self.lo.search( base = tmppos.getBase( ),scope = 'domain', filter = searchFilter, attr = [ 'zoneName', 'aRecord', 'aAAARecord' ], unique = 0 )
1172
1173
 Lines 1203-1209   def open( self ): Link Here 
1203
1204
1204
			if zoneNames:
1205
			if zoneNames:
1205
				for zoneName in zoneNames:
1206
				for zoneName in zoneNames:
1206
					searchFilter = filter_format('(&(objectClass=dNSZone)(|(PTRRecord=%s)(PTRRecord=%s.%s.)))', (self['name'], self['name'], zoneName[0]))
1207
					searchFilter = filter_format('(&(objectClass=dNSZone)(|(PTRRecord=%s)(PTRRecord=%s.%s.)))', (name, name, zoneName[0]))
1207
					try:
1208
					try:
1208
						results = self.lo.search( base = tmppos.getBase( ),scope = 'domain', attr = [ 'relativeDomainName', 'zoneName' ], filter = searchFilter, unique = 0 )
1209
						results = self.lo.search( base = tmppos.getBase( ),scope = 'domain', attr = [ 'relativeDomainName', 'zoneName' ], filter = searchFilter, unique = 0 )
1209
						for dn, attr in results:
1210
						for dn, attr in results:
 Lines 1221-1227   def open( self ): Link Here 
1221
1222
1222
			if zoneNames:
1223
			if zoneNames:
1223
				for zoneName in zoneNames:
1224
				for zoneName in zoneNames:
1224
					searchFilter = filter_format('(&(objectClass=dNSZone)(|(cNAMERecord=%s)(cNAMERecord=%s.%s.)))', (self['name'], self['name'], zoneName[0]))
1225
					searchFilter = filter_format('(&(objectClass=dNSZone)(|(cNAMERecord=%s)(cNAMERecord=%s.%s.)))', (name, name, zoneName[0]))
1225
					try:
1226
					try:
1226
						results = self.lo.search( base = tmppos.getBase( ),scope = 'domain', attr = [ 'relativeDomainName', 'cNAMERecord', 'zoneName' ], filter = searchFilter, unique = 0 )
1227
						results = self.lo.search( base = tmppos.getBase( ),scope = 'domain', attr = [ 'relativeDomainName', 'cNAMERecord', 'zoneName' ], filter = searchFilter, unique = 0 )
1227
						for dn, attr in results:
1228
						for dn, attr in results:
 Lines 1348-1353   def __modify_dhcp_object( self, position, name, ip, mac ): Link Here 
1348
1349
1349
	def __rename_dns_object( self, position = None, old_name = None, new_name = None ):
1350
	def __rename_dns_object( self, position = None, old_name = None, new_name = None ):
1350
		for dns_line in self[ 'dnsEntryZoneForward' ]:
1351
		for dns_line in self[ 'dnsEntryZoneForward' ]:
1352
			old_name = unicode(old_name).encode('idna')
1351
			# dns_line may be the empty string
1353
			# dns_line may be the empty string
1352
			if not dns_line:
1354
			if not dns_line:
1353
				continue
1355
				continue
 Lines 1498-1503   def modify(rdn, zoneDN): Link Here 
1498
		if dnsEntryZoneReverse:
1500
		if dnsEntryZoneReverse:
1499
			rdn = self.calc_dns_reverse_entry_name( ip, dnsEntryZoneReverse )
1501
			rdn = self.calc_dns_reverse_entry_name( ip, dnsEntryZoneReverse )
1500
			if rdn:
1502
			if rdn:
1503
				rdn = unicode(rdn).encode('idna')
1501
				modify(rdn, dnsEntryZoneReverse)
1504
				modify(rdn, dnsEntryZoneReverse)
1502
1505
1503
		elif ip:
1506
		elif ip:
 Lines 1518-1523   def modify(rdn, zoneDN): Link Here 
1518
	def __add_dns_reverse_object( self, name, zoneDn, ip ):
1521
	def __add_dns_reverse_object( self, name, zoneDn, ip ):
1519
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should create a dns reverse object: zoneDn="%s", name="%s", ip="%s"' % ( zoneDn, name, ip ) )
1522
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should create a dns reverse object: zoneDn="%s", name="%s", ip="%s"' % ( zoneDn, name, ip ) )
1520
		if name and zoneDn and ip:
1523
		if name and zoneDn and ip:
1524
			name = unicode(name).encode('idna')
1521
			univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'dns reverse object: start' )
1525
			univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'dns reverse object: start' )
1522
			hostname_list = []
1526
			hostname_list = []
1523
			if ':' in ip: # IPv6, e.g. ip=2001:db8:100::5
1527
			if ':' in ip: # IPv6, e.g. ip=2001:db8:100::5
 Lines 1580-1585   def __add_dns_reverse_object( self, name, zoneDn, ip ): Link Here 
1580
	def __remove_dns_forward_object( self, name, zoneDn, ip = None ):
1584
	def __remove_dns_forward_object( self, name, zoneDn, ip = None ):
1581
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should remove a dns forward object: zoneDn="%s", name="%s", ip="%s"' % ( zoneDn, name, ip ) )
1585
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should remove a dns forward object: zoneDn="%s", name="%s", ip="%s"' % ( zoneDn, name, ip ) )
1582
		if name:
1586
		if name:
1587
			name = unicode(name).encode('idna')
1583
			# check if dns forward object has more than one ip address
1588
			# check if dns forward object has more than one ip address
1584
			if not ip:
1589
			if not ip:
1585
				if zoneDn:
1590
				if zoneDn:
 Lines 1661-1666   def check_common_name_length(self): Link Here 
1661
	def __modify_dns_forward_object( self, name, zoneDn, new_ip, old_ip ):
1666
	def __modify_dns_forward_object( self, name, zoneDn, new_ip, old_ip ):
1662
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should modify a dns forward object: zoneDn="%s", name="%s", new_ip="%s", old_ip="%s"' % ( zoneDn, name, new_ip, old_ip ) )
1667
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'we should modify a dns forward object: zoneDn="%s", name="%s", new_ip="%s", old_ip="%s"' % ( zoneDn, name, new_ip, old_ip ) )
1663
		zone = None
1668
		zone = None
1669
		name = unicode(name).encode('idna')
1664
		if old_ip and new_ip:
1670
		if old_ip and new_ip:
1665
			if not zoneDn:
1671
			if not zoneDn:
1666
				tmppos = univention.admin.uldap.position( self.position.getDomain( ) )
1672
				tmppos = univention.admin.uldap.position( self.position.getDomain( ) )
 Lines 1718-1723   def __add_dns_forward_object( self, name, zoneDn, ip ): Link Here 
1718
1724
1719
	def __add_dns_forward_object_ipv6( self, name, zoneDn, ip ):
1725
	def __add_dns_forward_object_ipv6( self, name, zoneDn, ip ):
1720
		if name and ip and zoneDn:
1726
		if name and ip and zoneDn:
1727
			name = unicode(name).encode('idna')
1721
			ip = ipaddr.IPv6Address(ip).exploded
1728
			ip = ipaddr.IPv6Address(ip).exploded
1722
			results = self.lo.search( base = zoneDn, scope = 'domain', attr = [ 'aAAARecord' ], filter=filter_format('(&(relativeDomainName=%s)(!(cNAMERecord=*)))', (name,)), unique = 0 )
1729
			results = self.lo.search( base = zoneDn, scope = 'domain', attr = [ 'aAAARecord' ], filter=filter_format('(&(relativeDomainName=%s)(!(cNAMERecord=*)))', (name,)), unique = 0 )
1723
			if not results:
1730
			if not results:
 Lines 1746-1751   def __add_dns_forward_object_ipv6( self, name, zoneDn, ip ): Link Here 
1746
1753
1747
	def __add_dns_forward_object_ipv4( self, name, zoneDn, ip ):
1754
	def __add_dns_forward_object_ipv4( self, name, zoneDn, ip ):
1748
		if name and ip and zoneDn:
1755
		if name and ip and zoneDn:
1756
			name = unicode(name).encode('idna')
1749
			results = self.lo.search( base = zoneDn, scope = 'domain', attr = [ 'aRecord' ], filter=filter_format('(&(relativeDomainName=%s)(!(cNAMERecord=*)))', (name,)), unique = 0 )
1757
			results = self.lo.search( base = zoneDn, scope = 'domain', attr = [ 'aRecord' ], filter=filter_format('(&(relativeDomainName=%s)(!(cNAMERecord=*)))', (name,)), unique = 0 )
1750
			if not results:
1758
			if not results:
1751
				try:
1759
				try:
 Lines 1774-1779   def __add_dns_forward_object_ipv4( self, name, zoneDn, ip ): Link Here 
1774
1782
1775
	def __add_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias ):
1783
	def __add_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias ):
1776
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'add a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
1784
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'add a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
1785
		name = unicode(name).encode('idna')
1777
		if name and dnsForwardZone and dnsAliasZoneContainer and alias:
1786
		if name and dnsForwardZone and dnsAliasZoneContainer and alias:
1778
			results = self.lo.search( base = dnsAliasZoneContainer, scope = 'domain', attr = [ 'cNAMERecord' ], filter=filter_format('relativeDomainName=%s', (alias,)), unique = 0 )
1787
			results = self.lo.search( base = dnsAliasZoneContainer, scope = 'domain', attr = [ 'cNAMERecord' ], filter=filter_format('relativeDomainName=%s', (alias,)), unique = 0 )
1779
			if not results:
1788
			if not results:
 Lines 1795-1800   def __add_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, a Link Here 
1795
	def __remove_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias = None ):
1804
	def __remove_dns_alias_object( self, name, dnsForwardZone, dnsAliasZoneContainer, alias = None ):
1796
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'remove a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
1805
		univention.debug.debug( univention.debug.ADMIN, univention.debug.INFO, 'remove a dns alias object: name="%s", dnsForwardZone="%s", dnsAliasZoneContainer="%s", alias="%s"' % ( name, dnsForwardZone, dnsAliasZoneContainer, alias ) )
1797
		if name:
1806
		if name:
1807
			name = unicode(name).encode('idna')
1798
			if alias:
1808
			if alias:
1799
				if dnsAliasZoneContainer:
1809
				if dnsAliasZoneContainer:
1800
					self.lo.delete('relativeDomainName=%s,%s' % (ldap.dn.escape_dn_chars(alias), dnsAliasZoneContainer))
1810
					self.lo.delete('relativeDomainName=%s,%s' % (ldap.dn.escape_dn_chars(alias), dnsAliasZoneContainer))

Return to bug 34948