[python-win32] logon remote machine

pacopyc pacopyc pacopyc at gmail.com
Fri Nov 11 13:33:07 CET 2011


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.html>


More information about the python-win32 mailing list