diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-12-08 08:20:54 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-12-08 05:26:05 +0100 |
commit | 545932fda590d4c888c0f60fed7a36c1659f0018 (patch) | |
tree | 18bd10e6237e1c2489f25b4527cbd5bb260381ef /source4/scripting/python/samba/getopt.py | |
parent | 249afc8906bc33ed1e23f50f5c28a8ba0b8354c9 (diff) | |
download | samba-545932fda590d4c888c0f60fed7a36c1659f0018.tar.gz samba-545932fda590d4c888c0f60fed7a36c1659f0018.tar.xz samba-545932fda590d4c888c0f60fed7a36c1659f0018.zip |
samba-tools: more reasonable defaults for samba-tool commands
- fallback to machine account where possible
- default to local hostname where this is reasonable
Diffstat (limited to 'source4/scripting/python/samba/getopt.py')
-rw-r--r-- | source4/scripting/python/samba/getopt.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py index a5a33929845..671142b552e 100644 --- a/source4/scripting/python/samba/getopt.py +++ b/source4/scripting/python/samba/getopt.py @@ -151,7 +151,7 @@ class CredentialsOptions(optparse.OptionGroup): def _set_simple_bind_dn(self, option, opt_str, arg, parser): self.creds.set_bind_dn(arg) - def get_credentials(self, lp): + def get_credentials(self, lp, fallback_machine=False): """Obtain the credentials set on the command-line. :param lp: Loadparm object to use. @@ -160,6 +160,15 @@ class CredentialsOptions(optparse.OptionGroup): self.creds.guess(lp) if self.no_pass: self.creds.set_cmdline_callbacks() + + # possibly fallback to using the machine account, if we have + # access to the secrets db + if fallback_machine and not self.creds.authentication_requested(): + try: + self.creds.set_machine_account(lp) + except Exception: + pass + return self.creds class CredentialsOptionsDouble(CredentialsOptions): |