Win32 Impersonation

Giganews orl_ando74 at hotmail.com
Fri Mar 29 05:04:32 CET 2002


Hey all,

I'm a newbie with Python, and I have been looking for a way to run a script
as the administrator on Windows NT.  I have the user name and password, and
some code to do the impersonation, but when I try to use it, I receive a
sort of access denied message.  Upon reading the ActivePython docs, I found
that the user who runs the impersonation script needs SE_TCB_NAME,
SE_CHANGE_NOTIFY_NAME, and SE_ASSIGNPRIMARYTOKEN_NAME priveleges.

Maybe I'm missing the point here, but the only two accounts on these systems
with these priveleges are the administrator and the local system account.
Obviously, if I already were the administrator I wouldn't have this problem.
I think I'm missing something.

Anyway, here is the template of the code that I'm having problems with:

admin=win32security.LogonUser('administrator_account','domain','password')

win32security.ImpersonateLoggedOnUser(admin)


Has anyone gotten this to work on their systems, if so please help me!  Is
there another way?
Any help would be greatly appreciated,

Pablo Manzanera





More information about the Python-list mailing list