[python-win32] logon remote machine
pacopyc pacopyc
pacopyc at gmail.com
Mon Nov 14 19:00:01 CET 2011
Ok, I understood. Code is this:
handle = win32security.LogonUser('username', 'domain', 'password',
win32security.LOGON32_LOGON_NEW_CREDENTIALS,
win32security.LOGON32_LOGON_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(handle)
.......
I can connect to remote host with domain administrator user or with a valid
local user (also administrator) of remote host (in which case domain is
host's netbios_name). Code runs correctly.
Bye
pacopyc
2011/11/12 <python-win32-request at python.org>
> Send python-win32 mailing list submissions to
> python-win32 at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
> python-win32-request at python.org
>
> You can reach the person managing the list at
> python-win32-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
> 1. logon remote machine (pacopyc pacopyc)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 11 Nov 2011 13:33:07 +0100
> From: pacopyc pacopyc <pacopyc at gmail.com>
> To: python-win32 at python.org
> Subject: [python-win32] logon remote machine
> Message-ID:
> <CAJDkAOH-mFBTtMKF_jx85=t41_bo6hPQ9fxgUm_gyg4GdBe0qA at mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi, I must get OS and logged user on remote machine. I use this functions:
>
> 1) THIS FUNCTION IS OK (ALWAYS!!!!!!!)
> def getOperatingSystem(self,host):
> try:
> c = wmi.WMI(host, user="domain\user", password="password")
> os = c.win32_OperatingSystem()[0]
> except:
> ..............
>
> 2) THIS FUNCTION IS OK, BUT ONLY IF I EXECUTE SCRIPT (FUNCTION) AS HOST'S
> DOMAIN ADMINISTRATOR
> def getLoggedUser (self,host):
> logged_user = []
> res = 1
> while res:
> try:
> user_list, total, res2 =
> win32net.NetWkstaUserEnum(str(host), 0, res,
> win32netcon.MAX_PREFERRED_LENGTH)
> res = res2
> logged_user.append(user_list[1]['username'])
> except:
> ..............
>
> I'D LIKE EXECUTE getLoggedUser FUNCTION AS getOperatingSystem FUNCTION, I'D
> LIKE EXECUTE getLoggedUser FUNCTION NOT AS HOST'S DOMAIN ADMINISTRATOR BUT
> AS ANY USER.
>
> Can you help me?
> Thanks
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-win32/attachments/20111111/0d478bab/attachment-0001.html
> >
>
> ------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of python-win32 Digest, Vol 104, Issue 8
> ********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20111114/c79a79ce/attachment.html>
More information about the python-win32
mailing list