1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-06 08:59:08 +03:00

s4:upgradehelpers.py - use "clearTextPassword" rather than "userPassword"

It's the default internal s4 password change attribute
This commit is contained in:
Matthias Dieter Wallnöfer
2010-11-10 14:01:58 +01:00
parent 7c59ecec50
commit 2403aaa759

View File

@ -27,6 +27,7 @@ import string
import re
import shutil
import samba
import base64
from samba import Ldb, version, ntacls
from samba.dsdb import DS_DOMAIN_FUNCTION_2000
@ -827,12 +828,14 @@ 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)
msg["userPassword"] = ldb.MessageElement(machinepass,
ldb.FLAG_MOD_REPLACE,
"userPassword")
samdb.modify(msg)
samdb.modify_ldif("""
dn: """ + str(res[0].dn) + """
changetype: modify
replace: clearTextPassword
clearTextPassword:: """ + base64.b64encode(machinepass.encode('utf-16-le')) + """
""")
res = samdb.search(expression=("samAccountName=%s$" % names.netbiosname),
attrs=["msDs-keyVersionNumber"])