python: use the ldbMessage + modify notation instead of modify_ldif that we try to...
authorMatthieu Patou <mat@matws.net>
Fri, 12 Nov 2010 17:45:07 +0000 (20:45 +0300)
committerMatthieu Patou <mat@samba.org>
Fri, 12 Nov 2010 19:40:21 +0000 (19:40 +0000)
source4/scripting/python/samba/upgradehelpers.py

index b2bb66c5ea32b11cfcdbb70cfaeebf6aab300107..e8f14719a58fe25b0342aee84894178f60632f1b 100755 (executable)
@@ -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"])