1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_ldap - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.1</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_ldap</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_ldap.html" title="English"> en </a></p>
26 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>LDAP connection pooling and result caching services for use
27 by other LDAP modules</td></tr>
28 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
29 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>ldap_module</td></tr>
30 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>util_ldap.c</td></tr>
31 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.41 and later</td></tr></table>
34 <p>This module was created to improve the performance of
35 websites relying on backend connections to LDAP servers. In
36 addition to the functions provided by the standard LDAP
37 libraries, this module adds an LDAP connection pool and an LDAP
38 shared memory cache.</p>
40 <p>To enable this module, LDAP support must be compiled into
41 apr-util. This is achieved by adding the <code>--with-ldap</code>
42 flag to the <code>./configure</code> script when building
45 <p>SSL support requires that <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> be linked
46 with one of the following LDAP SDKs: <a href="http://www.openldap.org/">
47 OpenLDAP SDK</a> (both 1.x and 2.x), <a href="http://developer.novell.com/ndk/cldap.htm">
48 Novell LDAP SDK</a> or the <a href="http://www.iplanet.com/downloads/developer/">
49 iPlanet(Netscape)</a> SDK.</p>
52 <div id="quickview"><h3 class="directives">Directives</h3>
54 <li><img alt="" src="../images/down.gif" /> <a href="#ldapcacheentries">LDAPCacheEntries</a></li>
55 <li><img alt="" src="../images/down.gif" /> <a href="#ldapcachettl">LDAPCacheTTL</a></li>
56 <li><img alt="" src="../images/down.gif" /> <a href="#ldapopcacheentries">LDAPOpCacheEntries</a></li>
57 <li><img alt="" src="../images/down.gif" /> <a href="#ldapopcachettl">LDAPOpCacheTTL</a></li>
58 <li><img alt="" src="../images/down.gif" /> <a href="#ldapsharedcachefile">LDAPSharedCacheFile</a></li>
59 <li><img alt="" src="../images/down.gif" /> <a href="#ldapsharedcachesize">LDAPSharedCacheSize</a></li>
60 <li><img alt="" src="../images/down.gif" /> <a href="#ldaptrustedca">LDAPTrustedCA</a></li>
61 <li><img alt="" src="../images/down.gif" /> <a href="#ldaptrustedcatype">LDAPTrustedCAType</a></li>
65 <li><img alt="" src="../images/down.gif" /> <a href="#exampleconfig">Example Configuration</a></li>
66 <li><img alt="" src="../images/down.gif" /> <a href="#pool">LDAP Connection Pool</a></li>
67 <li><img alt="" src="../images/down.gif" /> <a href="#cache">LDAP Cache</a></li>
68 <li><img alt="" src="../images/down.gif" /> <a href="#usingssltls">Using SSL</a></li>
70 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
72 <h2><a name="exampleconfig" id="exampleconfig">Example Configuration</a></h2>
73 <p>The following is an example configuration that uses
74 <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> to increase the performance of HTTP Basic
75 authentication provided by <code class="module"><a href="../mod/mod_auth_ldap.html">mod_auth_ldap</a></code>.</p>
77 <div class="example"><p><code>
78 # Enable the LDAP connection pool and shared<br />
79 # memory cache. Enable the LDAP cache status<br />
80 # handler. Requires that mod_ldap and mod_auth_ldap<br />
81 # be loaded. Change the "yourdomain.example.com" to<br />
82 # match your domain.<br />
84 LDAPSharedCacheSize 200000<br />
85 LDAPCacheEntries 1024<br />
86 LDAPCacheTTL 600<br />
87 LDAPOpCacheEntries 1024<br />
88 LDAPOpCacheTTL 600<br />
90 <Location /ldap-status><br />
92 SetHandler ldap-status<br />
93 Order deny,allow<br />
95 Allow from yourdomain.example.com<br />
96 AuthLDAPEnabled on<br />
97 AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one<br />
98 AuthLDAPAuthoritative on<br />
99 require valid-user<br />
103 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
104 <div class="section">
105 <h2><a name="pool" id="pool">LDAP Connection Pool</a></h2>
107 <p>LDAP connections are pooled from request to request. This
108 allows the LDAP server to remain connected and bound ready for
109 the next request, without the need to unbind/connect/rebind.
110 The performance advantages are similar to the effect of HTTP
113 <p>On a busy server it is possible that many requests will try
114 and access the same LDAP server connection simultaneously.
115 Where an LDAP connection is in use, Apache will create a new
116 connection alongside the original one. This ensures that the
117 connection pool does not become a bottleneck.</p>
119 <p>There is no need to manually enable connection pooling in
120 the Apache configuration. Any module using this module for
121 access to LDAP services will share the connection pool.</p>
122 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
123 <div class="section">
124 <h2><a name="cache" id="cache">LDAP Cache</a></h2>
126 <p>For improved performance, <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> uses an aggressive
127 caching strategy to minimize the number of times that the LDAP
128 server must be contacted. Caching can easily double or triple
129 the throughput of Apache when it is serving pages protected
130 with mod_auth_ldap. In addition, the load on the LDAP server
131 will be significantly decreased.</p>
133 <p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> supports two types of LDAP caching during
134 the search/bind phase with a <em>search/bind cache</em> and
135 during the compare phase with two <em>operation
136 caches</em>. Each LDAP URL that is used by the server has
137 its own set of these three caches.</p>
139 <h3><a name="search-bind" id="search-bind">The Search/Bind Cache</a></h3>
140 <p>The process of doing a search and then a bind is the
141 most time-consuming aspect of LDAP operation, especially if
142 the directory is large. The search/bind cache is used to
143 cache all searches that resulted in successful binds.
144 Negative results (<em>i.e.</em>, unsuccessful searches, or searches
145 that did not result in a successful bind) are not cached.
146 The rationale behind this decision is that connections with
147 invalid credentials are only a tiny percentage of the total
148 number of connections, so by not caching invalid
149 credentials, the size of the cache is reduced.</p>
151 <p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> stores the username, the DN
152 retrieved, the password used to bind, and the time of the bind
153 in the cache. Whenever a new connection is initiated with the
154 same username, <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> compares the password
155 of the new connection with the password in the cache. If the
156 passwords match, and if the cached entry is not too old,
157 <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> bypasses the search/bind phase.</p>
159 <p>The search and bind cache is controlled with the <code class="directive"><a href="#ldapcacheentries">LDAPCacheEntries</a></code> and <code class="directive"><a href="#ldapcachettl">LDAPCacheTTL</a></code> directives.</p>
162 <h3><a name="opcaches" id="opcaches">Operation Caches</a></h3>
163 <p>During attribute and distinguished name comparison
164 functions, <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> uses two operation caches
165 to cache the compare operations. The first compare cache is
166 used to cache the results of compares done to test for LDAP
167 group membership. The second compare cache is used to cache
168 the results of comparisons done between distinguished
171 <p>The behavior of both of these caches is controlled with
172 the <code class="directive"><a href="#ldapopcacheentries">LDAPOpCacheEntries</a></code>
173 and <code class="directive"><a href="#ldapopcachettl">LDAPOpCacheTTL</a></code>
177 <h3><a name="monitoring" id="monitoring">Monitoring the Cache</a></h3>
178 <p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> has a content handler that allows
179 administrators to monitor the cache performance. The name of
180 the content handler is <code>ldap-status</code>, so the
181 following directives could be used to access the
182 <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> cache information:</p>
184 <div class="example"><p><code>
185 <Location /server/cache-info><br />
186 <span class="indent">
187 SetHandler ldap-status<br />
192 <p>By fetching the URL <code>http://servername/cache-info</code>,
193 the administrator can get a status report of every cache that is used
194 by <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> cache. Note that if Apache does not
195 support shared memory, then each <code>httpd</code> instance has its
196 own cache, so reloading the URL will result in different
197 information each time, depending on which <code>httpd</code>
198 instance processes the request.</p>
200 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
201 <div class="section">
202 <h2><a name="usingssltls" id="usingssltls">Using SSL</a></h2>
204 <p>The ability to create an SSL connections to an LDAP server
205 is defined by the directives <code class="directive"><a href="# ldaptrustedca">
206 LDAPTrustedCA</a></code> and <code class="directive"><a href="# ldaptrustedcatype">
207 LDAPTrustedCAType</a></code>. These directives specify the certificate
208 file or database and the certificate type. Whenever the LDAP url
209 includes <em>ldaps://</em>, <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> will establish
210 a secure connection to the LDAP server.</p>
212 <div class="example"><p><code>
213 # Establish an SSL LDAP connection. Requires that <br />
214 # mod_ldap and mod_auth_ldap be loaded. Change the <br />
215 # "yourdomain.example.com" to match your domain.<br />
217 LDAPTrustedCA /certs/certfile.der<br />
218 LDAPTrustedCAType DER_FILE<br />
220 <Location /ldap-status><br />
221 <span class="indent">
222 SetHandler ldap-status<br />
223 Order deny,allow<br />
225 Allow from yourdomain.example.com<br />
226 AuthLDAPEnabled on<br />
227 AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one<br />
228 AuthLDAPAuthoritative on<br />
229 require valid-user<br />
234 <p>If <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> is linked against the
235 Netscape/iPlanet LDAP SDK, it will not talk to any SSL server
236 unless that server has a certificate signed by a known Certificate
237 Authority. As part of the configuration
238 <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> needs to be told where it can find
239 a database containing the known CAs. This database is in the same
240 format as Netscape Communicator's <code>cert7.db</code>
241 database. The easiest way to get this file is to start up a fresh
242 copy of Netscape, and grab the resulting
243 <code>$HOME/.netscape/cert7.db</code> file.</p>
246 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
247 <div class="directive-section"><h2><a name="LDAPCacheEntries" id="LDAPCacheEntries">LDAPCacheEntries</a> <a name="ldapcacheentries" id="ldapcacheentries">Directive</a></h2>
248 <table class="directive">
249 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximum number of entries in the primary LDAP cache</td></tr>
250 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPCacheEntries <var>number</var></code></td></tr>
251 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LDAPCacheEntries 1024</code></td></tr>
252 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
253 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
254 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
256 <p>Specifies the maximum size of the primary LDAP cache. This
257 cache contains successful search/binds. Set it to 0 to turn off
258 search/bind caching. The default size is 1024 cached
262 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
263 <div class="directive-section"><h2><a name="LDAPCacheTTL" id="LDAPCacheTTL">LDAPCacheTTL</a> <a name="ldapcachettl" id="ldapcachettl">Directive</a></h2>
264 <table class="directive">
265 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Time that cached items remain valid</td></tr>
266 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPCacheTTL <var>seconds</var></code></td></tr>
267 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LDAPCacheTTL 600</code></td></tr>
268 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
269 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
270 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
272 <p>Specifies the time (in seconds) that an item in the
273 search/bind cache remains valid. The default is 600 seconds (10
277 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
278 <div class="directive-section"><h2><a name="LDAPOpCacheEntries" id="LDAPOpCacheEntries">LDAPOpCacheEntries</a> <a name="ldapopcacheentries" id="ldapopcacheentries">Directive</a></h2>
279 <table class="directive">
280 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Number of entries used to cache LDAP compare
282 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPOpCacheEntries <var>number</var></code></td></tr>
283 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LDAPOpCacheEntries 1024</code></td></tr>
284 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
285 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
286 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
288 <p>This specifies the number of entries <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>
289 will use to cache LDAP compare operations. The default is 1024
290 entries. Setting it to 0 disables operation caching.</p>
293 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
294 <div class="directive-section"><h2><a name="LDAPOpCacheTTL" id="LDAPOpCacheTTL">LDAPOpCacheTTL</a> <a name="ldapopcachettl" id="ldapopcachettl">Directive</a></h2>
295 <table class="directive">
296 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Time that entries in the operation cache remain
298 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPOpCacheTTL <var>seconds</var></code></td></tr>
299 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LDAPOpCacheTTL 600</code></td></tr>
300 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
301 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
302 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
304 <p>Specifies the time (in seconds) that entries in the
305 operation cache remain valid. The default is 600 seconds.</p>
308 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
309 <div class="directive-section"><h2><a name="LDAPSharedCacheFile" id="LDAPSharedCacheFile">LDAPSharedCacheFile</a> <a name="ldapsharedcachefile" id="ldapsharedcachefile">Directive</a></h2>
310 <table class="directive">
311 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the shared memory chache file</td></tr>
312 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPSharedCacheFile <var>directory-path/filename</var></code></td></tr>
313 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
314 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
315 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
317 <p>Specifies the directory path and file name of the shared memory
318 cache file. If not set, shared memory caching will not be used.</p>
321 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
322 <div class="directive-section"><h2><a name="LDAPSharedCacheSize" id="LDAPSharedCacheSize">LDAPSharedCacheSize</a> <a name="ldapsharedcachesize" id="ldapsharedcachesize">Directive</a></h2>
323 <table class="directive">
324 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Size in bytes of the shared-memory cache</td></tr>
325 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPSharedCacheSize <var>bytes</var></code></td></tr>
326 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LDAPSharedCacheSize 102400</code></td></tr>
327 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
328 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
329 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
331 <p>Specifies the number of bytes to allocate for the shared
332 memory cache. The default is 100kb. If set to 0, shared memory
333 caching will not be used.</p>
336 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
337 <div class="directive-section"><h2><a name="LDAPTrustedCA" id="LDAPTrustedCA">LDAPTrustedCA</a> <a name="ldaptrustedca" id="ldaptrustedca">Directive</a></h2>
338 <table class="directive">
339 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the file containing the trusted Certificate Authority certificate or database</td></tr>
340 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPTrustedCA <var>directory-path/filename</var></code></td></tr>
341 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
342 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
343 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
345 <p>It specifies the directory path and file name of the trusted CA
346 <code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code> should use when establishing an SSL
347 connection to an LDAP server. If using the Netscape/iPlanet Directory
348 SDK, the file name should be <code>cert7.db</code>.</p>
351 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
352 <div class="directive-section"><h2><a name="LDAPTrustedCAType" id="LDAPTrustedCAType">LDAPTrustedCAType</a> <a name="ldaptrustedcatype" id="ldaptrustedcatype">Directive</a></h2>
353 <table class="directive">
354 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Specifies the type of the Certificate Authority file</td></tr>
355 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LDAPTrustedCAType <var>type</var></code></td></tr>
356 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
357 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
358 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
360 <p>The following types are supported:<br />
361 DER_FILE - file in binary DER format<br />
362 BASE64_FILE - file in Base64 format<br />
363 CERT7_DB_PATH - Netscape certificate database file ")</p>
367 <div class="bottomlang">
368 <p><span>Available Languages: </span><a href="../en/mod/mod_ldap.html" title="English"> en </a></p>
369 </div><div id="footer">
370 <p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
371 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>