Python win32 tools

Tim Golden mail at timgolden.me.uk
Fri Mar 2 04:34:47 EST 2007


Sick Monkey wrote:
> I am trying to build a python program that will reset a user's account
> (password) on a windows machine. I have been working with win32
> objects and was wondering if this functionality was already built in.

I'm going to assume that "win32 objects" is the stuff in the
pywin32 extensions. While there isn't a "win32user.ResetPassword"
function in there, you can certainly use the win32com scripting
to automate ActiveDirectory and (trivially) translate this code:

   http://techtasks.com/code/viewbookcode/1592

And just to prove how wrong I can be :) the win32net module
*does* in fact have a function named NetUserChangePassword.
Doc:

"""
win32net.NetUserChangePassword
NetUserChangePassword(server, username, oldPassword, newPassword)

Changes the password for a user.

Comments
A server or domain can be configured to require that a user log on to 
change the password on a user account. If that is the case, you need 
administrator or account operator access to change the password for 
another user acount. If logging on is not required, you can change the 
password for any user account, so long as you know the current password.
"""

TJG



More information about the Python-list mailing list