mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
python: use the ldbMessage + modify notation instead of modify_ldif that we try to avoid
This commit is contained in:
committed by
Matthieu Patou
parent
5a6f3f14fb
commit
e0f64b77eb
@ -835,14 +835,13 @@ def update_machine_account_password(samdb, secrets_ldb, names):
|
|||||||
res = samdb.search(expression=expression, attrs=[])
|
res = samdb.search(expression=expression, attrs=[])
|
||||||
assert(len(res) == 1)
|
assert(len(res) == 1)
|
||||||
|
|
||||||
|
msg = ldb.Message(res[0].dn)
|
||||||
machinepass = samba.generate_random_password(128, 255)
|
machinepass = samba.generate_random_password(128, 255)
|
||||||
|
mputf16 = machinepass.encode('utf-16-le')
|
||||||
samdb.modify_ldif("""
|
msg["clearTextPassword"] = ldb.MessageElement(mputf16,
|
||||||
dn: """ + str(res[0].dn) + """
|
ldb.FLAG_MOD_REPLACE,
|
||||||
changetype: modify
|
"clearTextPassword")
|
||||||
replace: clearTextPassword
|
samdb.modify(msg)
|
||||||
clearTextPassword:: """ + base64.b64encode(machinepass.encode('utf-16-le')) + """
|
|
||||||
""")
|
|
||||||
|
|
||||||
res = samdb.search(expression=("samAccountName=%s$" % names.netbiosname),
|
res = samdb.search(expression=("samAccountName=%s$" % names.netbiosname),
|
||||||
attrs=["msDs-keyVersionNumber"])
|
attrs=["msDs-keyVersionNumber"])
|
||||||
|
Reference in New Issue
Block a user