[python-win32] Re: Is there a Python win32 RunAs equivalent where youcan send a password?

R. Alan Monroe amonroe at columbus.rr.com
Tue Mar 16 11:06:12 EST 2004


>> This looks really promising, but I've got some kind of rights problem:
>>
>>>>> a = impersonate.Impersonate('somebody', 'xxxxxx')
>>>>> a.logon()
>> pywintypes.error: (1314, 'LogonUser', 'A required privilege is not held by the client.')

> Look at the comments in the recipe - the full text is at
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81402/



A clarification for anyone else that ever needs to try this...

>The code is problematic as is. It may, or may not work. To enable
>this code on locked down NT based systems (Win2k and XP) you will
>first have to enable "Act as Operating System" and grant rights to
>the appropriate user groups (run secpol.msc and select Local
>Policies, then User Rights Assignments).

When you grant these rights, put in YOURSELF, the script runner, NOT
the future user that you will eventually impersonate within the script
itself! This drove me nuts until I tried it as a wild guess and
finally started working. Also, you have to reboot for policy changes
to take effect.


Alan




More information about the Python-win32 mailing list