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-requ...@python.org>

> Send python-win32 mailing list submissions to
>        python-win32@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-requ...@python.org
>
> You can reach the person managing the list at
>        python-win32-ow...@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 <paco...@gmail.com>
> To: python-win32@python.org
> Subject: [python-win32] logon remote machine
> Message-ID:
>        <CAJDkAOH-mFBTtMKF_jx85=t41_bo6hpq9fxgum_gyg4gdbe...@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@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of python-win32 Digest, Vol 104, Issue 8
> ********************************************
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to