Change Windows password using Python -
i developing little password manager tool using python. allows central password manager , single use passwords, therefor nobody ever know password of server , won't need change passwords when employee goes other employer.
anyway, design of software phone-home (and elimiate lot of firewall/natting issues) , run service. can sync users of system, verify if passwords got correct. resetting of password after logging in struggling @ moment.
win32.net netuserchangepassword seemd have want. (i thought) called "net user *". after testing figured out called netuserchangepassword feature of msvc libs. issue doesnt work when enter old-password none.
the process runs full-admin. , should able change user passwords without knowing old (disclaimer: unix background, root (superadmin) can everything, ciorrect me if wrong windows os).
so, how can super-admin change password localusers without knowing old password using python scripting language?
thanks!
update:
def set_password(username, password): win32com import adsi ads_obj = adsi.adsgetobject("winnt://localhost/%s,user" % username) ads_obj.getinfo() ads_obj.put('password', password) ads_obj.setinfo() def verify_success(username, password): win32security import logonuser win32con import logon32_logon_interactive, logon32_provider_default try: logonuser(username, none, password, logon32_logon_interactive, logon32_provider_default) except: return false return true u = "test_usr" p = "thenewstrongp@s$w0rd!" set_password(u, p) if verify_success(u, p): print "w00t workz" else: print "continue googling"
guess what, doesn't work.
in example. change:
ads_obj.put('password', password) ads_obj.setinfo()
with:
ads_obj.setpassword(password)
issue solved :)
Comments
Post a Comment