diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2019-03-26 19:50:35 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-04-30 23:18:29 +0000 |
commit | 35e52ebdd6498b2edcf57484a55439cb66319e45 (patch) | |
tree | 62893ced82d79c38d3d87b463adbb2bf312e5729 /python/samba | |
parent | e98340e3e2132c73ed002166e2e01dc761765b25 (diff) | |
download | samba-35e52ebdd6498b2edcf57484a55439cb66319e45.tar.gz |
traffic: define kerberos_state to simplify code
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r-- | python/samba/emulate/traffic.py | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 9d439a43054..dc13241d5ba 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -365,7 +365,10 @@ class ReplayContext(object): self.netlogon_connection = None self.creds = creds self.lp = lp - self.prefer_kerberos = prefer_kerberos + if prefer_kerberos: + self.kerberos_state = MUST_USE_KERBEROS + else: + self.kerberos_state = DONT_USE_KERBEROS self.ou = ou self.base_dn = base_dn self.domain = domain @@ -510,20 +513,14 @@ class ReplayContext(object): self.user_creds.set_password(self.userpass) self.user_creds.set_username(self.username) self.user_creds.set_domain(self.domain) - if self.prefer_kerberos: - self.user_creds.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.user_creds.set_kerberos_state(DONT_USE_KERBEROS) + self.user_creds.set_kerberos_state(self.kerberos_state) self.user_creds_bad = Credentials() self.user_creds_bad.guess(self.lp) self.user_creds_bad.set_workstation(self.netbios_name) self.user_creds_bad.set_password(self.userpass[:-4]) self.user_creds_bad.set_username(self.username) - if self.prefer_kerberos: - self.user_creds_bad.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.user_creds_bad.set_kerberos_state(DONT_USE_KERBEROS) + self.user_creds_bad.set_kerberos_state(self.kerberos_state) # Credentials for ldap simple bind. self.simple_bind_creds = Credentials() @@ -533,10 +530,7 @@ class ReplayContext(object): self.simple_bind_creds.set_username(self.username) self.simple_bind_creds.set_gensec_features( self.simple_bind_creds.get_gensec_features() | gensec.FEATURE_SEAL) - if self.prefer_kerberos: - self.simple_bind_creds.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.simple_bind_creds.set_kerberos_state(DONT_USE_KERBEROS) + self.simple_bind_creds.set_kerberos_state(self.kerberos_state) self.simple_bind_creds.set_bind_dn(self.user_dn) self.simple_bind_creds_bad = Credentials() @@ -547,10 +541,7 @@ class ReplayContext(object): self.simple_bind_creds_bad.set_gensec_features( self.simple_bind_creds_bad.get_gensec_features() | gensec.FEATURE_SEAL) - if self.prefer_kerberos: - self.simple_bind_creds_bad.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.simple_bind_creds_bad.set_kerberos_state(DONT_USE_KERBEROS) + self.simple_bind_creds_bad.set_kerberos_state(self.kerberos_state) self.simple_bind_creds_bad.set_bind_dn(self.user_dn) def generate_machine_creds(self): @@ -568,10 +559,7 @@ class ReplayContext(object): self.machine_creds.set_password(self.machinepass) self.machine_creds.set_username(self.netbios_name + "$") self.machine_creds.set_domain(self.domain) - if self.prefer_kerberos: - self.machine_creds.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.machine_creds.set_kerberos_state(DONT_USE_KERBEROS) + self.machine_creds.set_kerberos_state(self.kerberos_state) self.machine_creds_bad = Credentials() self.machine_creds_bad.guess(self.lp) @@ -579,10 +567,7 @@ class ReplayContext(object): self.machine_creds_bad.set_secure_channel_type(SEC_CHAN_BDC) self.machine_creds_bad.set_password(self.machinepass[:-4]) self.machine_creds_bad.set_username(self.netbios_name + "$") - if self.prefer_kerberos: - self.machine_creds_bad.set_kerberos_state(MUST_USE_KERBEROS) - else: - self.machine_creds_bad.set_kerberos_state(DONT_USE_KERBEROS) + self.machine_creds_bad.set_kerberos_state(self.kerberos_state) def get_matching_dn(self, pattern, attributes=None): # If the pattern is an empty string, we assume ROOTDSE, |