diff options
author | Matthieu Patou <mat@matws.net> | 2010-11-12 20:45:07 +0300 |
---|---|---|
committer | Matthieu Patou <mat@samba.org> | 2010-11-12 19:40:21 +0000 |
commit | e0f64b77ebb5ecbd1bdabe9f2b3cf368421b34e6 (patch) | |
tree | d86131ca052fd054f245d74b21d0110a76f460f4 | |
parent | 5a6f3f14fbf9bf96904e7f17e75aadac00427f96 (diff) | |
download | samba-e0f64b77ebb5ecbd1bdabe9f2b3cf368421b34e6.tar.gz samba-e0f64b77ebb5ecbd1bdabe9f2b3cf368421b34e6.tar.bz2 samba-e0f64b77ebb5ecbd1bdabe9f2b3cf368421b34e6.zip |
python: use the ldbMessage + modify notation instead of modify_ldif that we try to avoid
-rwxr-xr-x | source4/scripting/python/samba/upgradehelpers.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py index b2bb66c5ea..e8f14719a5 100755 --- a/source4/scripting/python/samba/upgradehelpers.py +++ b/source4/scripting/python/samba/upgradehelpers.py @@ -835,14 +835,13 @@ def update_machine_account_password(samdb, secrets_ldb, names): res = samdb.search(expression=expression, attrs=[]) assert(len(res) == 1) + msg = ldb.Message(res[0].dn) machinepass = samba.generate_random_password(128, 255) - - samdb.modify_ldif(""" -dn: """ + str(res[0].dn) + """ -changetype: modify -replace: clearTextPassword -clearTextPassword:: """ + base64.b64encode(machinepass.encode('utf-16-le')) + """ -""") + mputf16 = machinepass.encode('utf-16-le') + msg["clearTextPassword"] = ldb.MessageElement(mputf16, + ldb.FLAG_MOD_REPLACE, + "clearTextPassword") + samdb.modify(msg) res = samdb.search(expression=("samAccountName=%s$" % names.netbiosname), attrs=["msDs-keyVersionNumber"]) |