Users

Peter Hansen peter at engcorp.com
Thu Dec 9 20:10:51 CET 2004


python1 wrote:
> Do you know of a way to list the users on a Win2K machine? I can't seem 
> to find a module for this.

As a starting point, I played a moment and found this:

 >>> import win32net
 >>> dir(win32net)
['NetFileClose', 'NetFileEnum', 'NetFileGetInfo', ...
'NetUserEnum', 'NetUserGetGroups', 'NetUserGetInfo', ...]
 >>> win32net.NetUserEnum()
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: function takes at least 3 arguments (0 given)
 >>> win32net.NetUserEnum(0, 0, 0)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: Objects of type 'int' can not be converted to Unicode.
 >>> win32net.NetUserEnum('', 0, 0)
([{'name': u'Administrator'}, {'name': u'ASPNET'}, {'name': u'Elinor'}, 
{'name':
  u'Guest'}, {'name': u'HelpAssistant'}, {'name': u'Peter'}, {'name': 
u'postgres'
}, {'name': u'SUPPORT_388945a0'}], 8, 0)

Searching Google for NetUserEnum would probably be a good
next step.  Note that you will need pywin32 (formerly the
win32all) package installed to get win32net.

-Peter



More information about the Python-list mailing list