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 <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
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):