1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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 <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2023-03-02 14:45:40 +13:00 committed by Andrew Bartlett
parent 3861d7e09e
commit d4d3f93470

View File

@ -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 = []