CurrentUser for remote machine under NT

kellyk at my-deja.com kellyk at my-deja.com
Fri Jun 23 16:17:57 EDT 2000


In article <2B1262E83448D211AE4B00A0C9D61B0301301217 at msgeuro1.creo.be>,
  Pieter Claerhout <PClaerhout at CREO.BE> wrote:
> > Hello,
> >
> > how can you get the current logged in user for a remote nt system
using Python?
> >
> > Pieter
>

You can try this. It does not always work.

import win32pipe, string

workstation_name= "machinename"
workstation_userid= ""
lines= win32pipe.popen("nbtstat -a " + workstation_name).readlines()
for line in lines:
  fields= string.split(line)
  if len(fields) < 3:
    continue
  if fields[1] == "<03>" and string.upper(workstation_name) !=
fields[0]:
    workstation_userid= fields[0]
# prints blank if could not find
print workstation_userid


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list