<div>Ok, I understood. Code is this:</div><div><br></div><div>handle = win32security.LogonUser(&#39;username&#39;, &#39;domain&#39;, &#39;password&#39;, win32security.LOGON32_LOGON_NEW_CREDENTIALS, win32security.LOGON32_LOGON_PROVIDER_DEFAULT)</div>
<div>win32security.ImpersonateLoggedOnUser(handle)</div><div>.......</div><div><br></div><div>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&#39;s netbios_name). Code runs correctly.</div>
<div><br></div><div>Bye</div><div>pacopyc</div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">2011/11/12  <span dir="ltr">&lt;<a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Send python-win32 mailing list submissions to<br>
        <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:python-win32-owner@python.org">python-win32-owner@python.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of python-win32 digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. logon remote machine (pacopyc pacopyc)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 11 Nov 2011 13:33:07 +0100<br>
From: pacopyc pacopyc &lt;<a href="mailto:pacopyc@gmail.com">pacopyc@gmail.com</a>&gt;<br>
To: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
Subject: [python-win32] logon remote machine<br>
Message-ID:<br>
        &lt;CAJDkAOH-mFBTtMKF_jx85=<a href="mailto:t41_bo6hPQ9fxgUm_gyg4GdBe0qA@mail.gmail.com">t41_bo6hPQ9fxgUm_gyg4GdBe0qA@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
Hi, I must get OS and logged user on remote machine. I use this functions:<br>
<br>
1) THIS FUNCTION IS OK (ALWAYS!!!!!!!)<br>
    def getOperatingSystem(self,host):<br>
        try:<br>
            c = wmi.WMI(host, user=&quot;domain\user&quot;, password=&quot;password&quot;)<br>
            os = c.win32_OperatingSystem()[0]<br>
        except:<br>
            ..............<br>
<br>
2) THIS FUNCTION IS OK, BUT ONLY IF I EXECUTE SCRIPT (FUNCTION) AS HOST&#39;S<br>
DOMAIN ADMINISTRATOR<br>
    def getLoggedUser (self,host):<br>
        logged_user = []<br>
        res = 1<br>
        while res:<br>
            try:<br>
                user_list, total, res2 =<br>
win32net.NetWkstaUserEnum(str(host), 0, res,<br>
win32netcon.MAX_PREFERRED_LENGTH)<br>
                res = res2<br>
                logged_user.append(user_list[1][&#39;username&#39;])<br>
            except:<br>
                ..............<br>
<br>
I&#39;D LIKE EXECUTE getLoggedUser FUNCTION AS getOperatingSystem FUNCTION, I&#39;D<br>
LIKE EXECUTE getLoggedUser FUNCTION NOT AS HOST&#39;S DOMAIN ADMINISTRATOR BUT<br>
AS ANY USER.<br>
<br>
Can you help me?<br>
Thanks<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://mail.python.org/pipermail/python-win32/attachments/20111111/0d478bab/attachment-0001.html" target="_blank">http://mail.python.org/pipermail/python-win32/attachments/20111111/0d478bab/attachment-0001.html</a>&gt;<br>

<br>
------------------------------<br>
<br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
<br>
<br>
End of python-win32 Digest, Vol 104, Issue 8<br>
********************************************<br>
</blockquote></div><br>