File: ldap-async.tex

package info (click to toggle)
python-ldap-doc 2.3-1
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 200 kB
  • ctags: 121
  • sloc: python: 661; makefile: 44
file content (84 lines) | stat: -rw-r--r-- 2,046 bytes parent folder | download | duplicates (4)
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
% $Id: ldap-async.tex,v 1.2 2003/01/23 23:00:56 stroeder Exp $

\section{\module{ldap.async} ---
  Framework for stream-processing of large search results }

\declaremodule{standard}{ldap.async}

% Author of the module code;
\moduleauthor{Michael Str\"oder}{python-ldap-dev@lists.sourceforge.net}
% Author of the documentation,
\sectionauthor{Michael Str\"oder}{michael@stroeder.com}

\modulesynopsis{Framework for stream-processing of large search results.}

\subsection{Examples for ldap.async \label{ldap.async-example}}

\subsubsection{Using ldap.async.List \label{ldap.async-example.List}}

This example demonstrates how to use class ldap.async.List for
retrieving partial search results even though the exception
ldap.SIZELIMIT_EXCEEDED was raised because a server side limit was hit.

\begin{verbatim}
import sys,ldap,ldap.async

s = ldap.async.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)
  )
)
\end{verbatim}

\subsubsection{Using ldap.async.LDIFWriter \label{ldap.async-example.LDIFWriter}}

This example demonstrates how to use class ldap.async.LDIFWriter
for writing search results as LDIF to stdout.

\begin{verbatim}
import sys,ldap,ldap.async

s = ldap.async.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
  )
)
\end{verbatim}