diff options
author | Zahari Zahariev <zahari.zahariev@postpath.com> | 2010-01-13 10:41:56 +0200 |
---|---|---|
committer | Nadezhda Ivanova <nadezhda.ivanova@postpath.com> | 2010-01-13 12:06:17 +0200 |
commit | 5d1aa4c5b796ad5e65f7447414d09c059f060946 (patch) | |
tree | 09a67c22ecfabecface70cd8818ba77e2d959b77 /source4/scripting/python | |
parent | 9b3871ed293f76e770e572cd6b59f59670f1f6f8 (diff) | |
download | samba-5d1aa4c5b796ad5e65f7447414d09c059f060946.tar.gz samba-5d1aa4c5b796ad5e65f7447414d09c059f060946.tar.bz2 samba-5d1aa4c5b796ad5e65f7447414d09c059f060946.zip |
Comparison tool for LDAP servers (using Ldb)
This tool is integrated with Samba4 Ldb. It provides a useful output
where you can find easy differences in objects or attributes within
naming context (Domain, Configuration or Schema).
Added functionality for two sets of credentials.
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/getopt.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py index 48d48dc260..a62bd5ae5a 100644 --- a/source4/scripting/python/samba/getopt.py +++ b/source4/scripting/python/samba/getopt.py @@ -114,3 +114,55 @@ class CredentialsOptions(optparse.OptionGroup): if not self.no_pass: self.creds.set_cmdline_callbacks() return self.creds + +class CredentialsOptionsDouble(CredentialsOptions): + """Command line options for specifying credentials of two servers.""" + def __init__(self, parser): + CredentialsOptions.__init__(self, parser) + self.no_pass2 = False + self.add_option("--simple-bind-dn2", metavar="DN2", action="callback", + callback=self._set_simple_bind_dn2, type=str, + help="DN to use for a simple bind") + self.add_option("--password2", metavar="PASSWORD2", action="callback", + help="Password", type=str, callback=self._set_password2) + self.add_option("--username2", metavar="USERNAME2", + action="callback", type=str, + help="Username for second server", callback=self._parse_username2) + self.add_option("--workgroup2", metavar="WORKGROUP2", + action="callback", type=str, + help="Workgroup for second server", callback=self._parse_workgroup2) + self.add_option("--no-pass2", action="store_true", + help="Don't ask for a password for the second server") + self.add_option("--kerberos2", metavar="KERBEROS2", + action="callback", type=str, + help="Use Kerberos", callback=self._set_kerberos2) + self.creds2 = Credentials() + + def _parse_username2(self, option, opt_str, arg, parser): + self.creds2.parse_string(arg) + + def _parse_workgroup2(self, option, opt_str, arg, parser): + self.creds2.set_domain(arg) + + def _set_password2(self, option, opt_str, arg, parser): + self.creds2.set_password(arg) + + def _set_kerberos2(self, option, opt_str, arg, parser): + if bool(arg) or arg.lower() == "yes": + self.creds2.set_kerberos_state(MUST_USE_KERBEROS) + else: + self.creds2.set_kerberos_state(DONT_USE_KERBEROS) + + def _set_simple_bind_dn2(self, option, opt_str, arg, parser): + self.creds2.set_bind_dn(arg) + + def get_credentials2(self, lp): + """Obtain the credentials set on the command-line. + + :param lp: Loadparm object to use. + :return: Credentials object + """ + self.creds2.guess(lp) + if not self.no_pass2: + self.creds2.set_cmdline_callbacks() + return self.creds2 |