File: ldapurl.tex

package info (click to toggle)
python-ldap-doc 2.3-2.1
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 200 kB
  • ctags: 121
  • sloc: python: 661; makefile: 44
file content (125 lines) | stat: -rw-r--r-- 3,539 bytes parent folder | download | duplicates (3)
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
115
116
117
118
119
120
121
122
123
124
125
% $Id: ldapurl.tex,v 1.9 2007/03/27 22:10:17 stroeder Exp $

% ==== 1. ====
% The section prologue.  Give the section a title and provide some
% meta-information.  References to the module should use
% \refbimodindex, \refstmodindex, \refexmodindex or \refmodindex, as
% appropriate.

\section{\module{ldapurl} ---
         LDAP URL handling}

\declaremodule{standard}{ldapurl}

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

% Leave at least one blank line after this, to simplify ad-hoc tools
% that are sometimes used to massage these files.
\modulesynopsis{Parses and generates LDAP URLs}


% ==== 2. ====
% Give a short overview of what the module does.
% If it is platform specific, mention this.
% Mention other important restrictions or general operating principles.

This module parses and generates LDAP URLs.

It is implemented in pure Python and does not rely on any
non-standard modules. Therefore it can be used stand-alone without
the rest of the python-ldap package.

Compability note: This module has been solely tested on Python 2.x and above.

The \module{ldapurl} module exports the following constants:

\begin{datadesc}{SEARCH_SCOPE}
  This dictionary maps a search scope string identifier
  to the corresponding integer value used with search operations
  in \module{ldap}.
\end{datadesc}

\begin{datadesc}{SEARCH_SCOPE_STR}
  This dictionary is the inverse to \constant{SEARCH_SCOPE}. It
  maps a search scope integer value to the corresponding string identifier
  used in a LDAP URL string representation.
\end{datadesc}

\begin{datadesc}{LDAP_SCOPE_BASE}
  
\end{datadesc}

\begin{datadesc}{LDAP_SCOPE_ONELEVEL}
  
\end{datadesc}

\begin{datadesc}{LDAP_SCOPE_SUBTREE}
  
\end{datadesc}


\begin{seealso}
\seerfc{4516}{The LDAP URL Format}{}
\end{seealso}

\subsection{LDAPUrl Objects \label{ldapurl-ldapurl}}
A \class{LDAPUrl} object represents a complete LDAP URL.

All class methods:

Class attributes:

Instance attributes:


\subsection{LDAPUrlExtension Objects \label{ldapurl-ldapurlextension}}
A \class{LDAPUrlExension} object represents a single LDAP URL extension.

All class methods:

Class attributes:

Instance attributes:


\subsection{Example \label{ldapurl-example}}

Important security advice:
For security reasons you shouldn't specify passwords in LDAP URLs
unless you really know what you are doing.

The following example demonstrates how to parse a LDAP URL
with \module{ldapurl} module.

\begin{verbatim}
>>> import ldapurl
>>> ldap_url = ldapurl.LDAPUrl('ldap://localhost:1389/dc=stroeder,dc=com?cn,mail???bindname=cn=Michael%2cdc=stroeder%2cdc=com,X-BINDPW=secret')
>>> # Using the parsed LDAP URL by reading the class attributes
>>> ldap_url.dn
'dc=stroeder,dc=com'
>>> ldap_url.hostport
'localhost:1389'
>>> ldap_url.attrs
['cn','mail']
>>> ldap_url.filterstr
'(objectclass=*)'
>>> ldap_url.who
'cn=Michael,dc=stroeder,dc=com'
>>> ldap_url.cred
'secret'
>>> ldap_url.scope
0
\end{verbatim}

The following example demonstrates how to generate a LDAP URL
with \module{ldapurl} module.

\begin{verbatim}
>>> import ldapurl
>>> ldap_url = ldapurl.LDAPUrl(hostport='localhost:1389',dn='dc=stroeder,dc=com',attrs=['cn','mail'],who='cn=Michael,dc=stroeder,dc=com',cred='secret')
>>> ldap_url.unparse()
'ldap://localhost:1389/dc=stroeder,dc=com?cn,mail?base?(objectclass=*)?bindname=cn=Michael%2Cdc=stroeder%2Cdc=com,X-BINDPW=secret'
\end{verbatim}