Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add paging to ldap search #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TheoAndersen
Copy link

on larger directories, a single-query can exceed the size limit of a
single search, giving the errorr (SIZE_EXCEEDED).

This commit changes the ldap search to use paging, whereas multiple
search requests of a default size of 1000 results are made.

This was created with inspiration from the following sources:

on larger directories, a single-query can exceed the size limit of a
single search, giving the errorr (SIZE_EXCEEDED).

This commit changes the ldap search to use paging, whereas multiple
search requests of a default size of 1000 results are made.

This was created with inspiration from the following sources:
 - https://gist.github.com/mattfahrner/c228ead9c516fc322d3a
 - https://bitbucket.org/jaraco/python-ldap/src/f208b6338a28/Demo/paged_search_ext_s.py?fileviewer=file-view-default
@troelsarvin
Copy link

Verified working with three different Active Directories.

@@ -114,7 +114,8 @@ def bind():
"""This function will bind to the LDAP instance and return an ldapobject."""

ldapobject = ldap.initialize(url)

ldapobject.protocol_version = ldap.VERSION3 #paging results only apply to LDAP v3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to turn this into a CLI option? If you can manipulate these options as you have without affecting other AD versions or LDAP servers, it wouldn't matter but I'm not sure.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, sure i can make the ldap protocol version, into a cli option (with 3 being the default)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LDAP 3 has existed since 1997, and LDAP 2 officially died in 2003. That's a while back... So I assert it's not worth the added complexity to add an LDAP version parameter.

@whitlockjc
Copy link
Owner

So the LDAP version is a CLI option but paging (and its options) aren't. Thoughts?

@TheoAndersen
Copy link
Author

You have a point that these might be related, and i did add the LDAP version CLI addition, mainly because of your comments.

The paging ldap functionality is part of ldap v3, and dates to 1999. Its RFC is here RFC2696. So it would seem quite old.

I don't really know the users of this project very well, so I really cannot say whether this change would be a breaking change.

Otherwise one would have to look into adding functionality, which would make the script able to detect wether paging is possible, and fall back to the old logic if it isn't. But thats fairly more complex code.

@TheoAndersen TheoAndersen mentioned this pull request Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants