summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-01-10 15:15:19 +0100
committerStefan Metzmacher <metze@samba.org>2012-01-12 22:15:58 +0100
commit5efe29baed70b0cbe732350a02b24fc23016e552 (patch)
tree464d66cc679038cd798977865eda87a348b5ea9f /source4/scripting
parent9a8b72a3180b6aa1beb4b153867d4f9f0df953a1 (diff)
downloadsamba-5efe29baed70b0cbe732350a02b24fc23016e552.tar.gz
samba-5efe29baed70b0cbe732350a02b24fc23016e552.tar.bz2
samba-5efe29baed70b0cbe732350a02b24fc23016e552.zip
s4:repl_cleartext_pwd.py: add 'attmode' parameter to convert the attname to utf8
metze
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/devel/repl_cleartext_pwd.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/source4/scripting/devel/repl_cleartext_pwd.py b/source4/scripting/devel/repl_cleartext_pwd.py
index 576f4b85f1..d4ad6f0846 100755
--- a/source4/scripting/devel/repl_cleartext_pwd.py
+++ b/source4/scripting/devel/repl_cleartext_pwd.py
@@ -76,15 +76,19 @@ def attid_equal(a1,a2):
########### main code ###########
if __name__ == "__main__":
- parser = OptionParser("repl_cleartext_pwd.py [options] server dn cookie_file cleartext_name [attid attname]")
+ parser = OptionParser("repl_cleartext_pwd.py [options] server dn cookie_file cleartext_name [attid attname attmode]")
sambaopts = options.SambaOptions(parser)
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
(opts, args) = parser.parse_args()
- if len(args) < 4 or len(args) == 5:
- parser.error("more arguments required")
+ if len(args) == 4:
+ pass
+ elif len(args) >= 7:
+ pass
+ else:
+ parser.error("more arguments required - given=%d" % (len(args)))
server = args[0]
dn = args[1]
@@ -92,15 +96,19 @@ if __name__ == "__main__":
if len(cookie_file) == 0:
cookie_file = None
cleartext_name = args[3]
- if len(args) >= 5:
+ if len(args) >= 7:
try:
attid = int(args[4], 16)
except:
attid = int(args[4])
attname = args[5]
+ attmode = args[6]
+ if attmode not in ["raw", "utf8"]:
+ parser.error("attmode should be 'raw' or 'utf8'")
else:
attid = -1
attname = None
+ attmode = "raw"
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
@@ -252,7 +260,16 @@ if __name__ == "__main__":
attvals = []
for j in range(0, attr.value_ctr.num_values):
assert attr.value_ctr.values[j].blob is not None
- attvals.append(attr.value_ctr.values[j].blob)
+ val_raw = attr.value_ctr.values[j].blob
+ val = None
+ if attmode == "utf8":
+ val_unicode = unicode(val_raw, 'utf-16-le')
+ val = val_unicode.encode('utf-8')
+ elif attmode == "raw":
+ val = val_raw
+ else:
+ assert False, "attmode[%s]" % attmode
+ attvals.append(val)
if not attid_equal(attr.attid, drsuapi.DRSUAPI_ATTID_supplementalCredentials):
continue
assert attr.value_ctr.num_values <= 1