summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-27 23:31:42 -0600
committerStefan Metzmacher <metze@samba.org>2007-12-27 17:36:05 -0600
commit094f364fe172a117fd1cf8ae1855fd72fca8e5b4 (patch)
tree81ffa6a480ef14514e9d496e7eeed0e637e5d392
parent70cb5ac03c476110c0348881f49ad0697037ca38 (diff)
downloadsamba-094f364fe172a117fd1cf8ae1855fd72fca8e5b4.tar.gz
samba-094f364fe172a117fd1cf8ae1855fd72fca8e5b4.tar.bz2
samba-094f364fe172a117fd1cf8ae1855fd72fca8e5b4.zip
r26614: Fix options parsing for credentials in Python.
(This used to be commit 9ef3b7de6baadeb2240ef9d24c55be9dc4cccf1e)
-rw-r--r--source4/scripting/python/samba/getopt.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 8143dcafdb..3335c55bc6 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -35,12 +35,24 @@ class VersionOptions(optparse.OptionGroup):
class CredentialsOptions(optparse.OptionGroup):
def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Credentials Options")
- self.add_option("--simple-bind-dn", type="string", metavar="DN",
+ self.add_option("--simple-bind-dn", metavar="DN", action="callback",
+ callback=self.set_simple_bind_dn, type=str,
help="DN to use for a simple bind")
- self.add_option("--password", type="string", metavar="PASSWORD",
- help="Password")
+ self.add_option("--password", metavar="PASSWORD", action="callback",
+ help="Password", type=str, callback=self.set_password)
+ self.add_option("-U", "--username", metavar="USERNAME",
+ action="callback", type=str,
+ help="username", callback=self.parse_username)
+ self.creds = Credentials()
+
+ def parse_username(self, option, opt_str, arg, parser):
+ self.creds.parse_string(arg)
+
+ def set_password(self, option, opt_str, arg, parser):
+ self.creds.set_password(arg)
+
+ def set_simple_bind_dn(self, option, opt_str, arg, parser):
+ self.creds.set_simple_bind_dn(arg)
def get_credentials(self):
- creds = Credentials()
- # FIXME: Update
- return creds
+ return self.creds