[python-win32] win32com.adsi limits number of members returned

Tim Golden mail at timgolden.me.uk
Sat Jun 16 06:12:23 CEST 2012


On 15/06/2012 22:43, Matt LaPlante wrote:
> Using the following code...
>
> import win32com.adsi
> DNC=win32com.adsi.ADsGetObject('LDAP://rootDSE').Get('DefaultNamingContext')
> path = 'LDAP://cn=BIG_GROUP,ou=Groups,'+DNC
> groupobj = win32com.adsi.ADsGetObject(path)
> users = groupobj.member
> print len(users)
>
> The output is always a maximum 1500, even if BIG_GROUP contains
> several thousand members. How can I execute this query in a way that
> returns all members of BIG_GROUP?

(Sorry, quick answer for now just to set on the right route.)

This is a built-in limitation. I can't get a web connection at the 
moment but if you search MSDN for "attribute range retrieval" you should 
find a description. In principle you could use GetInfoEx but at present 
it's not implemented in the pywin32 ADSI code. Instead you might craft 
your LDAP query with a range qualifier to see if that worked.

TJG


More information about the python-win32 mailing list