1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

r26614: Fix options parsing for credentials in Python.

(This used to be commit 9ef3b7de6b)
This commit is contained in:
Jelmer Vernooij 2007-12-27 23:31:42 -06:00 committed by Stefan Metzmacher
parent 70cb5ac03c
commit 094f364fe1

View File

@ -35,12 +35,24 @@ class VersionOptions(optparse.OptionGroup):
class CredentialsOptions(optparse.OptionGroup): class CredentialsOptions(optparse.OptionGroup):
def __init__(self, parser): def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Credentials Options") 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") help="DN to use for a simple bind")
self.add_option("--password", type="string", metavar="PASSWORD", self.add_option("--password", metavar="PASSWORD", action="callback",
help="Password") 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): def get_credentials(self):
creds = Credentials() return self.creds
# FIXME: Update
return creds