]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_ldap.xml
`build check-ja` :-)
[apache] / docs / manual / mod / mod_ldap.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4
5 <!--
6  Copyright 2002-2004 The Apache Software Foundation
7
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11
12      http://www.apache.org/licenses/LICENSE-2.0
13
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 -->
20
21 <modulesynopsis metafile="mod_ldap.xml.meta">
22
23 <name>mod_ldap</name>
24 <description>LDAP connection pooling and result caching services for use
25 by other LDAP modules</description>
26 <status>Experimental</status>
27 <sourcefile>util_ldap.c</sourcefile>
28 <identifier>ldap_module</identifier>
29 <compatibility>Available in version 2.0.41 and later</compatibility>
30
31 <summary>
32     <p>This module was created to improve the performance of
33     websites relying on backend connections to LDAP servers. In
34     addition to the functions provided by the standard LDAP
35     libraries, this module adds an LDAP connection pool and an LDAP
36     shared memory cache.</p>
37
38     <p>To enable this module, LDAP support must be compiled into
39     apr-util. This is achieved by adding the <code>--with-ldap</code>
40     flag to the <code>./configure</code> script when building
41     Apache.</p>
42
43     <p>SSL support requires that <module>mod_ldap</module> be linked
44     with one of the following LDAP SDKs: <a href="http://www.openldap.org/">
45     OpenLDAP SDK</a> (both 1.x and 2.x), <a href="http://developer.novell.com/ndk/cldap.htm">
46     Novell LDAP SDK</a> or the <a href="http://www.iplanet.com/downloads/developer/">
47     iPlanet(Netscape)</a> SDK.</p>
48
49 </summary>
50
51 <section id="exampleconfig"><title>Example Configuration</title>
52     <p>The following is an example configuration that uses
53     <module>mod_ldap</module> to increase the performance of HTTP Basic
54     authentication provided by <module>mod_auth_ldap</module>.</p>
55
56     <example>
57       # Enable the LDAP connection pool and shared<br />
58       # memory cache. Enable the LDAP cache status<br />
59       # handler. Requires that mod_ldap and mod_auth_ldap<br />
60       # be loaded. Change the "yourdomain.example.com" to<br />
61       # match your domain.<br />
62       <br />
63       LDAPSharedCacheSize 200000<br />
64       LDAPCacheEntries 1024<br />
65       LDAPCacheTTL 600<br />
66       LDAPOpCacheEntries 1024<br />
67       LDAPOpCacheTTL 600<br />
68       <br />
69       &lt;Location /ldap-status&gt;<br />
70       <indent>
71         SetHandler ldap-status<br />
72         Order deny,allow<br />
73         Deny from all<br />
74         Allow from yourdomain.example.com<br />
75         AuthLDAPEnabled on<br />
76         AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one<br />
77         AuthLDAPAuthoritative on<br />
78         require valid-user<br />
79       </indent>
80       &lt;/Location&gt;
81     </example>
82 </section>
83
84 <section id="pool"><title>LDAP Connection Pool</title>
85
86     <p>LDAP connections are pooled from request to request. This
87     allows the LDAP server to remain connected and bound ready for
88     the next request, without the need to unbind/connect/rebind.
89     The performance advantages are similar to the effect of HTTP
90     keepalives.</p>
91
92     <p>On a busy server it is possible that many requests will try
93     and access the same LDAP server connection simultaneously.
94     Where an LDAP connection is in use, Apache will create a new
95     connection alongside the original one. This ensures that the
96     connection pool does not become a bottleneck.</p>
97
98     <p>There is no need to manually enable connection pooling in
99     the Apache configuration. Any module using this module for
100     access to LDAP services will share the connection pool.</p>
101 </section>
102
103 <section id="cache"><title>LDAP Cache</title>
104
105     <p>For improved performance, <module>mod_ldap</module> uses an aggressive
106     caching strategy to minimize the number of times that the LDAP
107     server must be contacted. Caching can easily double or triple
108     the throughput of Apache when it is serving pages protected
109     with mod_auth_ldap. In addition, the load on the LDAP server
110     will be significantly decreased.</p>
111
112     <p><module>mod_ldap</module> supports two types of LDAP caching during
113     the search/bind phase with a <em>search/bind cache</em> and
114     during the compare phase with two <em>operation
115     caches</em>. Each LDAP URL that is used by the server has
116     its own set of these three caches.</p>
117
118     <section id="search-bind"><title>The Search/Bind Cache</title>
119       <p>The process of doing a search and then a bind is the
120       most time-consuming aspect of LDAP operation, especially if
121       the directory is large. The search/bind cache is used to
122       cache all searches that resulted in successful binds.
123       Negative results (<em>i.e.</em>, unsuccessful searches, or searches
124       that did not result in a successful bind) are not cached.
125       The rationale behind this decision is that connections with
126       invalid credentials are only a tiny percentage of the total
127       number of connections, so by not caching invalid
128       credentials, the size of the cache is reduced.</p>
129
130       <p><module>mod_ldap</module> stores the username, the DN
131       retrieved, the password used to bind, and the time of the bind
132       in the cache. Whenever a new connection is initiated with the
133       same username, <module>mod_ldap</module> compares the password
134       of the new connection with the password in the cache. If the
135       passwords match, and if the cached entry is not too old,
136       <module>mod_ldap</module> bypasses the search/bind phase.</p>
137
138       <p>The search and bind cache is controlled with the <directive
139       module="mod_ldap">LDAPCacheEntries</directive> and <directive
140       module="mod_ldap">LDAPCacheTTL</directive> directives.</p>
141     </section>
142
143     <section id="opcaches"><title>Operation Caches</title>
144       <p>During attribute and distinguished name comparison
145       functions, <module>mod_ldap</module> uses two operation caches
146       to cache the compare operations. The first compare cache is
147       used to cache the results of compares done to test for LDAP
148       group membership. The second compare cache is used to cache
149       the results of comparisons done between distinguished
150       names.</p>
151
152       <p>The behavior of both of these caches is controlled with
153       the <directive module="mod_ldap">LDAPOpCacheEntries</directive>
154       and <directive module="mod_ldap">LDAPOpCacheTTL</directive>
155       directives.</p>
156     </section>
157
158     <section id="monitoring"><title>Monitoring the Cache</title>
159       <p><module>mod_ldap</module> has a content handler that allows
160       administrators to monitor the cache performance. The name of
161       the content handler is <code>ldap-status</code>, so the
162       following directives could be used to access the
163       <module>mod_ldap</module> cache information:</p>
164
165       <example>
166         &lt;Location /server/cache-info&gt;<br />
167         <indent>
168           SetHandler ldap-status<br />
169         </indent>
170         &lt;/Location&gt;
171       </example>
172
173       <p>By fetching the URL <code>http://servername/cache-info</code>,
174       the administrator can get a status report of every cache that is used
175       by <module>mod_ldap</module> cache. Note that if Apache does not
176       support shared memory, then each <code>httpd</code> instance has its
177       own cache, so reloading the URL will result in different
178       information each time, depending on which <code>httpd</code>
179       instance processes the request.</p>
180     </section>
181 </section>
182
183 <section id="usingssltls"><title>Using SSL</title>
184
185     <p>The ability to create an SSL connections to an LDAP server 
186     is defined by the directives <directive module="mod_ldap">
187     LDAPTrustedCA</directive> and <directive module="mod_ldap">
188     LDAPTrustedCAType</directive>. These directives specify the certificate
189     file or database and the certificate type. Whenever the LDAP url
190     includes <em>ldaps://</em>, <module>mod_ldap</module> will establish
191     a secure connection to the LDAP server.</p>
192
193     <example>
194       # Establish an SSL LDAP connection. Requires that <br />
195       # mod_ldap and mod_auth_ldap be loaded. Change the <br />
196       # "yourdomain.example.com" to match your domain.<br />
197       <br />
198       LDAPTrustedCA /certs/certfile.der<br />
199       LDAPTrustedCAType DER_FILE<br />
200       <br />
201       &lt;Location /ldap-status&gt;<br />
202       <indent>
203         SetHandler ldap-status<br />
204         Order deny,allow<br />
205         Deny from all<br />
206         Allow from yourdomain.example.com<br />
207         AuthLDAPEnabled on<br />
208         AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one<br />
209         AuthLDAPAuthoritative on<br />
210         require valid-user<br />
211       </indent>
212       &lt;/Location&gt;
213     </example>
214
215     <p>If <module>mod_ldap</module> is linked against the
216     Netscape/iPlanet LDAP SDK, it will not talk to any SSL server
217     unless that server has a certificate signed by a known Certificate
218     Authority. As part of the configuration
219     <module>mod_ldap</module> needs to be told where it can find
220     a database containing the known CAs. This database is in the same
221     format as Netscape Communicator's <code>cert7.db</code>
222     database. The easiest way to get this file is to start up a fresh
223     copy of Netscape, and grab the resulting
224     <code>$HOME/.netscape/cert7.db</code> file.</p>
225
226 </section>
227
228 <directivesynopsis>
229 <name>LDAPSharedCacheSize</name>
230 <description>Size in bytes of the shared-memory cache</description>
231 <syntax>LDAPSharedCacheSize <var>bytes</var></syntax>
232 <default>LDAPSharedCacheSize 102400</default>
233 <contextlist><context>server config</context></contextlist>
234
235 <usage>
236     <p>Specifies the number of bytes to allocate for the shared
237     memory cache. The default is 100kb. If set to 0, shared memory
238     caching will not be used.</p>
239 </usage>
240 </directivesynopsis>
241
242 <directivesynopsis>
243 <name>LDAPSharedCacheFile</name>
244 <description>Sets the shared memory chache file</description>
245 <syntax>LDAPSharedCacheFile <var>directory-path/filename</var></syntax>
246 <contextlist><context>server config</context></contextlist>
247
248 <usage>
249     <p>Specifies the directory path and file name of the shared memory
250     cache file. If not set, shared memory caching will not be used.</p>
251 </usage>
252 </directivesynopsis>
253
254 <directivesynopsis>
255 <name>LDAPCacheEntries</name>
256 <description>Maximum number of entries in the primary LDAP cache</description>
257 <syntax>LDAPCacheEntries <var>number</var></syntax>
258 <default>LDAPCacheEntries 1024</default>
259 <contextlist><context>server config</context></contextlist>
260
261 <usage>
262     <p>Specifies the maximum size of the primary LDAP cache. This
263     cache contains successful search/binds. Set it to 0 to turn off
264     search/bind caching. The default size is 1024 cached
265     searches.</p>
266 </usage>
267 </directivesynopsis>
268
269 <directivesynopsis>
270 <name>LDAPCacheTTL</name>
271 <description>Time that cached items remain valid</description>
272 <syntax>LDAPCacheTTL <var>seconds</var></syntax>
273 <default>LDAPCacheTTL 600</default>
274 <contextlist><context>server config</context></contextlist>
275
276 <usage>
277     <p>Specifies the time (in seconds) that an item in the
278     search/bind cache remains valid. The default is 600 seconds (10
279     minutes).</p>
280 </usage>
281 </directivesynopsis>
282
283 <directivesynopsis>
284 <name>LDAPOpCacheEntries</name>
285 <description>Number of entries used to cache LDAP compare 
286 operations</description>
287 <syntax>LDAPOpCacheEntries <var>number</var></syntax>
288 <default>LDAPOpCacheEntries 1024</default>
289 <contextlist><context>server config</context></contextlist>
290
291 <usage>
292     <p>This specifies the number of entries <module>mod_ldap</module>
293     will use to cache LDAP compare operations. The default is 1024
294     entries.  Setting it to 0 disables operation caching.</p>
295 </usage>
296 </directivesynopsis>
297
298 <directivesynopsis>
299 <name>LDAPOpCacheTTL</name>
300 <description>Time that entries in the operation cache remain
301 valid</description>
302 <syntax>LDAPOpCacheTTL <var>seconds</var></syntax>
303 <default>LDAPOpCacheTTL 600</default>
304 <contextlist><context>server config</context></contextlist>
305
306 <usage>
307     <p>Specifies the time (in seconds) that entries in the
308     operation cache remain valid. The default is 600 seconds.</p>
309 </usage>
310 </directivesynopsis>
311
312 <directivesynopsis>
313 <name>LDAPTrustedCA</name>
314 <description>Sets the file containing the trusted Certificate Authority certificate or database</description>
315 <syntax>LDAPTrustedCA <var>directory-path/filename</var></syntax>
316 <contextlist><context>server config</context></contextlist>
317
318 <usage>
319     <p>It specifies the directory path and file name of the trusted CA
320     <module>mod_ldap</module> should use when establishing an SSL
321     connection to an LDAP server. If using the Netscape/iPlanet Directory
322     SDK, the file name should be <code>cert7.db</code>.</p>
323 </usage>
324 </directivesynopsis>
325
326 <directivesynopsis>
327 <name>LDAPTrustedCAType</name>
328 <description>Specifies the type of the Certificate Authority file</description>
329 <syntax>LDAPTrustedCAType <var>type</var></syntax>
330 <contextlist><context>server config</context></contextlist>
331
332 <usage>
333     <p>The following types are supported:<br />
334           DER_FILE      - file in binary DER format<br />
335           BASE64_FILE   - file in Base64 format<br />
336           CERT7_DB_PATH - Netscape certificate database file ")</p>
337 </usage>
338 </directivesynopsis>
339
340 </modulesynopsis>