Users
python1
python1 at spamless.net
Thu Dec 9 13:49:57 EST 2004
Tim Golden wrote:
> [python1]
> | Do you know of a way to list the users on a Win2K machine? I
> | can't seem to find a module for this.
>
> Interpretation 1: who is in the user database of a given machine?
Sorry for the ambiguity. Yes #1 is correct. I'll try the code you've
listed...
Thanks.
> Investigate the win32net module. Something like this:
>
> <code>
> import win32net
> import win32netcon
>
> MACHINE_NAME = 'VOGBP200'
>
> resume = 0
> while 1:
> (_users, total, resume) = \
> win32net.NetUserEnum (
> MACHINE_NAME,
> 1,
> win32netcon.FILTER_NORMAL_ACCOUNT,
> resume,
> win32netcon.MAX_PREFERRED_LENGTH
> )
> for _user in _users:
> print _user['name']
> if not resume:
> break
> </code>
>
> Using active directory might also be a possibility.
> As with many such questions, the first question is:
> how do you do this in Windows generally? And then:
> how do you translate that to Python?
>
> Interpretation 2: who is currently logged on to the machine?
>
> This is more difficult. On XP / 2003, there are WMI classes
> to tell you this (Win32_LoggedOnUser) but not on 2000.
> Likewise, there are LsaEnumerateLogonSessions in XP+,
> but not on 2000.
>
> Anyone else got any ideas?
>
> TJG
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
More information about the Python-list
mailing list