[python-ldap] Why is Active Directory refusing to support a simple paged results search?

Sean Whalen whalenster at gmail.com
Mon Oct 3 16:32:44 EDT 2016


 I'm trying to use python-ldap to run a a simple paged search on an Active
Directory server.

See RFC 2696 <https://www.ietf.org/rfc/rfc2696.txt>

Simplified sample code:

import ldapfrom ldap.controls import SimplePagedResultsControl

SERVER = "dc.example.net"
USERNAME = "ADLookup"
PASSWORD = "12345LuggageAmazing"
BASE = "dc=example, dc=net"
FILTER = "(sAMAccountName=sean.whalen)"
PAGE_SIZE = 1000

ad = ldap.initialize("ldap://{0}".format(SERVER), trace_level=2)
ad.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3)
ad.set_option(ldap.OPT_REFERRALS, 0)

ad.simple_bind(USERNAME, PASSWORD)

pc = SimplePagedResultsControl(criticality=True, size=PAGE_SIZE, cookie="")

msgid = ad.search_ext(BASE,
                      scope=ldap.SCOPE_SUBTREE,
                      filterstr=FILTER,
                      clientctrls=[pc])
# Skipping over processing because it the exception is raised at the above call

Output:

=> result:1*** <ldap.ldapobject.SimpleLDAPObject object at
0x7fb00f27f7f0> ldap://dc.example.net -
SimpleLDAPObject.search_ext(('dc=example,dc=net',
  2,
  '(sAMAccountName=sean.whalen)',
  None,
  0,
  None,
  [('1.2.840.113556.1.4.319', True, b'0\x06\x02\x02\x03\xe8\x04\x00')],
  -1,
  0),
 {})=> LDAPError - NOT_SUPPORTED: {'desc': 'Not Supported'}

Is is possible that the server admins have disabled paged searches, or is
something wrong with my code?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20161003/288699d4/attachment.html>


More information about the python-ldap mailing list