s4:scripting/python: add support for utf-8 passwords from the command line
authorStefan Metzmacher <metze@samba.org>
Mon, 4 Feb 2013 10:41:39 +0000 (11:41 +0100)
committerKarolin Seeger <kseeger@samba.org>
Tue, 5 Feb 2013 09:46:48 +0000 (10:46 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit d60be8167b7264dadae7d4735ee5977233d4cea9)

source4/scripting/python/samba/samdb.py

index d83e0a6f7c8c5ebcd1869131b49b327026e9c613..5478e24c34e6307486ea0772516a0980025f6387 100644 (file)
@@ -449,12 +449,13 @@ member: %s
             if len(res) > 1:
                 raise Exception('Matched %u multiple users with filter "%s"' % (len(res), search_filter))
             user_dn = res[0].dn
+            pw = unicode('"' + password + '"', 'utf-8').encode('utf-16-le')
             setpw = """
 dn: %s
 changetype: modify
 replace: unicodePwd
 unicodePwd:: %s
-""" % (user_dn, base64.b64encode(("\"" + password + "\"").encode('utf-16-le')))
+""" % (user_dn, base64.b64encode(pw))
 
             self.modify_ldif(setpw)