<div>Ok, I understood. Code is this:</div><div><br></div><div>handle = win32security.LogonUser('username', 'domain', 'password', 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'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"><<a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a>></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 'help' 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 "Re: Contents of python-win32 digest..."<br>
<br>
<br>
Today'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 <<a href="mailto:pacopyc@gmail.com">pacopyc@gmail.com</a>><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>
<CAJDkAOH-mFBTtMKF_jx85=<a href="mailto:t41_bo6hPQ9fxgUm_gyg4GdBe0qA@mail.gmail.com">t41_bo6hPQ9fxgUm_gyg4GdBe0qA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<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="domain\user", password="password")<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'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]['username'])<br>
except:<br>
..............<br>
<br>
I'D LIKE EXECUTE getLoggedUser FUNCTION AS getOperatingSystem FUNCTION, I'D<br>
LIKE EXECUTE getLoggedUser FUNCTION NOT AS HOST'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: <<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>><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>