Article
Problem
A Forum reader recently asked:
"I am wondering whether any version of eDirectory supports a paging search that returns partial results each time. I know that the PagedResultsControl LDAP V3 control can provide me such functionality. We tried it in our current eDirectory version, but we got an "Operation not supported" error. "
And here's the response from Michael Stroder ...
Solution
For python-ldap, see the example below for simple paged results (Demo/page_control.py).
url = "ldap://localhost:1390/"
base = "dc=stroeder,dc=de"
search_flt = r'(objectClass=*)'
page_size = 10
import ldap
from ldap.controls import SimplePagedResultsControl
ldap.set_option(ldap.OPT_REFERRALS, 0)
l = ldap.initialize(url)
l.protocol_version = 3
l.simple_bind_s("", "")
lc = SimplePagedResultsControl(
ldap.LDAP_CONTROL_PAGE_OID,True,(page_size,'')
)
# Send search request
msgid = l.search_ext(
base,
ldap.SCOPE_SUBTREE,
search_flt,
serverctrls=[lc]
)
pages = 0
while True:
pages += 1
print "Getting page %d" % (pages,)
rtype, rdata, rmsgid, serverctrls = l.result3(msgid)
print '%d results' % len(rdata)
pctrls = [
c
for c in serverctrls
if c.controlType == ldap.LDAP_CONTROL_PAGE_OID
]
if pctrls:
est, cookie = pctrls[0].controlValue
if cookie:
lc.controlValue = (page_size, cookie)
msgid = l.search_ext(base, ldap.SCOPE_SUBTREE, search_flt,
serverctrls=[lc])
else:
break
else:
print "Warning: Server ignores RFC 2696 control."
break Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 6917 reads


0