@classmethod
def setUpClass(cls):
- cls.lp = cls.get_loadparm(cls)
+ cls._lp = None
cls.host = os.environ["SERVER"]
cls._ldb = None
self.do_asn1_print = global_asn1_print
self.do_hexdump = global_hexdump
+ def get_lp(self):
+ if self._lp is None:
+ type(self)._lp = self.get_loadparm()
+
+ return self._lp
+
def get_samdb(self):
if self._ldb is None:
creds = self.get_user_creds()
+ lp = self.get_lp()
session = system_session()
type(self)._ldb = SamDB(url="ldap://%s" % self.host,
session_info=session,
credentials=creds,
- lp=self.lp)
+ lp=lp)
return self._ldb
ldb.add(details)
creds = Credentials()
- creds.guess(self.lp)
+ creds.guess(self.get_lp())
creds.set_realm(ldb.domain_dns_name().upper())
creds.set_domain(ldb.domain_netbios_name().upper())
creds.set_password(password)
creds.set_kerberos_state(MUST_USE_KERBEROS)
creds.set_username(user_name, SPECIFIED)
creds.set_realm(realm)
- creds.set_named_ccache(cachefile.name, SPECIFIED, self.lp)
+ creds.set_named_ccache(cachefile.name, SPECIFIED, self.get_lp())
# Return the credentials along with the cache file.
return (creds, cachefile)
# Authenticate in-process to the machine account using the user's
# cached credentials.
+ lp = self.get_lp()
+
settings = {}
- settings["lp_ctx"] = self.lp
+ settings["lp_ctx"] = lp
settings["target_hostname"] = mach_name
gensec_client = gensec.Security.start_client(settings)
gensec_client.want_feature(gensec.FEATURE_SEAL)
gensec_client.start_mech_by_sasl_name("GSSAPI")
- auth_context = AuthContext(lp_ctx=self.lp, ldb=samdb, methods=[])
+ auth_context = AuthContext(lp_ctx=lp, ldb=samdb, methods=[])
gensec_server = gensec.Security.start_server(settings, auth_context)
gensec_server.set_credentials(mach_credentials)
# Connect to the machine account and retrieve the user SID.
ldb_as_user = SamDB(url="ldap://%s" % mach_name,
credentials=creds,
- lp=self.lp)
+ lp=self.get_lp())
ldb_res = ldb_as_user.search('',
scope=SCOPE_BASE,
attrs=["tokenGroups"])
# cached credentials.
binding_str = "ncacn_np:%s[\\pipe\\lsarpc]" % mach_name
- conn = lsa.lsarpc(binding_str, self.lp, creds)
+ conn = lsa.lsarpc(binding_str, self.get_lp(), creds)
(account_name, _) = conn.GetUserName(None, None, None)
# Connect to a share and retrieve the user SID.
s3_lp = s3param.get_context()
- s3_lp.load(self.lp.configfile)
+ s3_lp.load(self.get_lp().configfile)
min_protocol = s3_lp.get("client min protocol")
self.addCleanup(s3_lp.set, "client min protocol", min_protocol)