Re: [python-win32] runas analog

2019-03-18 Thread Vernon D. Cole
Perhaps ShellExecuteEx will do what you are wishing for?
I found a good formula for starting a process as an administrator and it is
packaged in
a small module

tries to emulate a "sudo" command. You might look at the code around line
76.

Starting a subprocess in Windows is somewhat of a black art, I fear.



On Mon, Mar 18, 2019 at 7:16 PM Kuree Kafir  wrote:

> Hello,
>
> I am trying to implement something similar to the runas /netonly command
> in python.
>
> handle = win32security.LogonUser(userName, domain, password,
> win32con.LOGON32_LOGON_NEW_CREDENTIALS, win32con.LOGON32_PROVIDER_DEFAULT)
> win32security.ImpersonateLoggedOnUser(handle)
>
> These two commands succeed, and I can see the credentials in memory, but
> when I attempt to call something like os.system("cmd.exe") and attempt to
> authenticate, the security context previous created is not presented, and
> authentication fails.
>
> How do I correctly call CreateProcess using the impersonation session that
> I just created?
>
> kuree
> ___
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] runas analog

2019-03-18 Thread Kuree Kafir
Hello,

I am trying to implement something similar to the runas /netonly command in
python.

handle = win32security.LogonUser(userName, domain, password,
win32con.LOGON32_LOGON_NEW_CREDENTIALS, win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(handle)

These two commands succeed, and I can see the credentials in memory, but
when I attempt to call something like os.system("cmd.exe") and attempt to
authenticate, the security context previous created is not presented, and
authentication fails.

How do I correctly call CreateProcess using the impersonation session that
I just created?

kuree
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32