1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
********************************************************************
:py:mod:`ldap.asyncsearch` Stream-processing of large search results
********************************************************************
.. py:module:: ldap.asyncsearch
:synopsis: Framework for stream-processing of large search results.
With newer Python versions one might want to consider using
:py:mod:`ldap.resiter` instead.
.. versionchanged:: 3.0
In Python 3.7 ``async`` is a reserved keyword. The module
:py:mod:`ldap.async` has been renamed to :py:mod:`ldap.asyncsearch`. The
old name :py:mod:`ldap.async` is still available for backwards
compatibility.
.. deprecated:: 3.0
The old name :py:mod:`ldap.async` is deprecated, but will not be removed
until Python 3.6 reaches end-of-life.
Classes
=======
.. autoclass:: ldap.asyncsearch.AsyncSearchHandler
:members:
.. autoclass:: ldap.asyncsearch.List
:members:
.. autoclass:: ldap.asyncsearch.Dict
:members:
.. autoclass:: ldap.asyncsearch.IndexedDict
:members:
.. autoclass:: ldap.asyncsearch.LDIFWriter
:members:
.. _ldap.asyncsearch-example:
Examples
========
.. _ldap.asyncsearch-example.List:
Using ldap.asyncsearch.List
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This example demonstrates how to use class ldap.asyncsearch.List for
retrieving partial search results even though the exception
:exc:`ldap.SIZELIMIT_EXCEEDED` was raised because a server side limit was hit. ::
import sys,ldap,ldap.asyncsearch
s = ldap.asyncsearch.List(
ldap.initialize('ldap://localhost'),
)
s.startSearch(
'dc=stroeder,dc=com',
ldap.SCOPE_SUBTREE,
'(objectClass=*)',
)
try:
partial = s.processResults()
except ldap.SIZELIMIT_EXCEEDED:
sys.stderr.write('Warning: Server-side size limit exceeded.\n')
else:
if partial:
sys.stderr.write('Warning: Only partial results received.\n')
sys.stdout.write(
'%d results received.\n' % (
len(s.allResults)
)
)
.. _ldap.asyncsearch-example.LDIFWriter:
Using ldap.asyncsearch.LDIFWriter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This example demonstrates how to use class ldap.asyncsearch.LDIFWriter
for writing search results as LDIF to stdout. ::
import sys,ldap,ldap.asyncsearch
s = ldap.asyncsearch.LDIFWriter(
ldap.initialize('ldap://localhost:1390'),
sys.stdout
)
s.startSearch(
'dc=stroeder,dc=com',
ldap.SCOPE_SUBTREE,
'(objectClass=*)',
)
try:
partial = s.processResults()
except ldap.SIZELIMIT_EXCEEDED:
sys.stderr.write('Warning: Server-side size limit exceeded.\n')
else:
if partial:
sys.stderr.write('Warning: Only partial results received.\n')
sys.stderr.write(
'%d results received.\n' % (
s.endResultBreak-s.beginResultsDropped
)
)
|