From d4d3f93470fa9c26a1ede32a036289731cc932cf Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Thu, 2 Mar 2023 14:45:40 +1300 Subject: [PATCH] tests/krb5: Lazily fetch SamDB in get_default_enctypes() There's no need to get a connection to SamDB if we already have the domain functional level. connect_kdc() in lockout_tests.py is one place where we already have the domain functional level, but deliberately drop our SamDB connection. If we need to call get_default_enctypes(), that shouldn't cause us to try to connect again. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- python/samba/tests/krb5/kdc_base_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/samba/tests/krb5/kdc_base_test.py b/python/samba/tests/krb5/kdc_base_test.py index 99a630415b3..a7baa574dbb 100644 --- a/python/samba/tests/krb5/kdc_base_test.py +++ b/python/samba/tests/krb5/kdc_base_test.py @@ -292,8 +292,11 @@ class KDCBaseTest(RawKerberosTest): return self._rodc_ctx - def get_domain_functional_level(self, ldb): + def get_domain_functional_level(self, ldb=None): if self._functional_level is None: + if ldb is None: + ldb = self.get_samdb() + res = ldb.search(base='', scope=SCOPE_BASE, attrs=['domainFunctionality']) @@ -307,8 +310,7 @@ class KDCBaseTest(RawKerberosTest): return self._functional_level def get_default_enctypes(self): - samdb = self.get_samdb() - functional_level = self.get_domain_functional_level(samdb) + functional_level = self.get_domain_functional_level() default_enctypes = []