win32com and adsi

Max M maxm at
Fri Aug 23 11:05:09 CEST 2002

Lars Kellogg-Stedman wrote:

>   from win32com import *
>   pdc = GetObject('WinNT://DOMAIN')
>   pdc.Filter = ['User']
>   for user in pdc:
>     print user.Name

> Is this idiom supported by the win32com module?  Or are there any 
> glaring errors in what I'm trying to do?

Isn't it a collection object. Then your iteration is special-cased by 
VBScript which does the following for you under the cover(untested)?:

pdc = GetObject('WinNT://DOMAIN')
pdc.Filter = ['User']
for i in range(1, pdc.count + 1): # ugh
     key  = pdc.Key(i)
     print pdc(key)

A good ide would probably be to write a function that simply converts a 
collection to a dict.

regards Max M

More information about the Python-list mailing list