tags:

views:

47

answers:

2

I am getting an ldap.SIZELIMIT_EXCEEDED error when I run this code:

import ldap

url = 'ldap://<domain>:389'
binddn = 'cn=<username> readonly,cn=users,dc=tnc,dc=org'
password = '<password>'

conn = ldap.initialize(url)
conn.simple_bind_s(binddn,password)

base_dn = "ou=People,dc=tnc,dc=org"
filter = '(objectClass=*)'
attrs = ['sn']

conn.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs )

Where is my actual username, my actual password, and the actual domain.

I don't understand why this is. Can somebody shed some light?

Thanks! :) Eric

+1  A: 

Manual: http://www.python-ldap.org/doc/html/ldap.html

exception ldap.SIZELIMIT_EXCEEDED
An LDAP size limit was exceeded. This could be due to a sizelimit configuration on the LDAP server.

I think your best bet here is to limit the sizelimit on the message you receive from the server. You can do that by setting the attribute LDAPObject.sizelimit (deprecated) or using the sizelimit parameter when using search_ext()

You should also make sure your bind was actually successful...

NullUserException
Thanks for this. I guess that should have been my first source.
Eric
A: 

Active Directory defaults to returning a max of 1000 results. What is sort of annoying is that rather than return 1000, with an associated error code, it seems to send the error code without the data.

eDirectory starts with no default, and is completely conifgurable to whatever you like.

Other directories handle it differently. (Edit and add in, if you know).

geoffc
I figured that that was happening. So, what I do now is return query by first letter of last name. This is a better idea than showing thousands of employees at one time.
Eric
Oh, and thanks! :)
Eric
Be aware that searching by first letter of a name does not work. Since eventually your data set will get large enough to return more than 1000 S's and so on...
geoffc