From 6bd2f82b9ff7629effe8280ab8f6bf9d721cf767 Mon Sep 17 00:00:00 2001 From: Aaron Haslett Date: Tue, 10 Jul 2018 13:23:42 +1200 Subject: [PATCH] dns: Use ldb.SCOPE_SUBTREE in ldap_get_records() routine in tests/dns.py DNS records have the odd property that the DN can be reliably determined by the name only, so we do not need a subtree search. However by using a subtree search under the zone we can without trapping exceptions confirm if the record exists or not in the tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10812 Signed-off-by: Aaron Haslett Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer --- python/samba/tests/dns.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 52505560e1c..c0f71dbf633 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -969,9 +969,11 @@ class TestZones(DNSTest): return recs[0] def ldap_get_records(self, name): - dn = 'DC={},{}'.format(name, self.zone_dn) + # The use of SCOPE_SUBTREE here avoids raising an exception in the + # 0 results case for a test below. + expr = "(&(objectClass=dnsNode)(name={}))".format(name) - return self.samdb.search(base=dn, scope=ldb.SCOPE_SUBTREE, + return self.samdb.search(base=self.zone_dn, scope=ldb.SCOPE_SUBTREE, expression=expr, attrs=["*"]) def ldap_get_dns_records(self, name): -- 2.34.1