mod_ldap.xml revision ecc6e723b804fb4b8f858910eff3f88242ec56fa
<?xml version="1.0"?>
<!-- $LastChangedRevision$ -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<modulesynopsis metafile="mod_ldap.xml.meta">
<name>mod_ldap</name>
<description>LDAP connection pooling and result caching services for use
by other LDAP modules</description>
<status>Extension</status>
<identifier>ldap_module</identifier>
<compatibility>Available in version 2.0.41 and later</compatibility>
<summary>
<p>This module was created to improve the performance of
websites relying on backend connections to LDAP servers. In
addition to the functions provided by the standard LDAP
libraries, this module adds an LDAP connection pool and an LDAP
shared memory cache.</p>
<p>To enable this module, LDAP support must be compiled into
apr-util. This is achieved by adding the <code>--with-ldap</code>
flag to the <program>configure</program> script when building
Apache.</p>
linked to <glossary>APR</glossary>. As of this writing, APR-util supports:
<a href="http://developer.novell.com/ndk/cldap.htm">Novell LDAP
Mozilla LDAP SDK</a>, native Solaris LDAP SDK (Mozilla based),
native Microsoft LDAP SDK, or the
<a href="http://www.iplanet.com/downloads/developer/">iPlanet
website for details.</p>
</summary>
<section id="exampleconfig"><title>Example Configuration</title>
<p>The following is an example configuration that uses
<module>mod_ldap</module> to increase the performance of HTTP Basic
authentication provided by <module>mod_authnz_ldap</module>.</p>
<example>
# Enable the LDAP connection pool and shared<br />
# memory cache. Enable the LDAP cache status<br />
# handler. Requires that mod_ldap and mod_authnz_ldap<br />
# be loaded. Change the "yourdomain.example.com" to<br />
# match your domain.<br />
<br />
LDAPSharedCacheSize 500000<br />
LDAPCacheEntries 1024<br />
LDAPCacheTTL 600<br />
LDAPOpCacheEntries 1024<br />
LDAPOpCacheTTL 600<br />
<br />
<Location /ldap-status><br />
<indent>
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
Satisfy any<br />
AuthType Basic<br />
AuthName "LDAP Protected"<br />
AuthBasicProvider ldap<br />
Require valid-user<br />
</indent>
</Location>
</example>
</section>
<section id="pool"><title>LDAP Connection Pool</title>
<p>LDAP connections are pooled from request to request. This
allows the LDAP server to remain connected and bound ready for
The performance advantages are similar to the effect of HTTP
keepalives.</p>
<p>On a busy server it is possible that many requests will try
and access the same LDAP server connection simultaneously.
Where an LDAP connection is in use, Apache will create a new
connection alongside the original one. This ensures that the
connection pool does not become a bottleneck.</p>
<p>There is no need to manually enable connection pooling in
the Apache configuration. Any module using this module for
access to LDAP services will share the connection pool.</p>
<p>LDAP connections can keep track of the ldap client
credentials used when binding to an LDAP server. These
credentials can be provided to LDAP servers that do not
allow anonymous binds during referral chasing. To control
this feature, see the <directive module="mod_ldap">
LDAPReferrals</directive> and <directive module="mod_ldap">
LDAPReferralHopLimit</directive> directives. By default,
this feature is enabled.</p>
</section>
<section id="cache"><title>LDAP Cache</title>
<p>For improved performance, <module>mod_ldap</module> uses an aggressive
caching strategy to minimize the number of times that the LDAP
server must be contacted. Caching can easily double or triple
the throughput of Apache when it is serving pages protected
with mod_authnz_ldap. In addition, the load on the LDAP server
will be significantly decreased.</p>
<p><module>mod_ldap</module> supports two types of LDAP caching during
during the compare phase with two <em>operation
caches</em>. Each LDAP URL that is used by the server has
its own set of these three caches.</p>
<p>The process of doing a search and then a bind is the
most time-consuming aspect of LDAP operation, especially if
cache all searches that resulted in successful binds.
that did not result in a successful bind) are not cached.
The rationale behind this decision is that connections with
invalid credentials are only a tiny percentage of the total
number of connections, so by not caching invalid
credentials, the size of the cache is reduced.</p>
<p><module>mod_ldap</module> stores the username, the DN
retrieved, the password used to bind, and the time of the bind
in the cache. Whenever a new connection is initiated with the
same username, <module>mod_ldap</module> compares the password
of the new connection with the password in the cache. If the
passwords match, and if the cached entry is not too old,
<p>The search and bind cache is controlled with the <directive
module="mod_ldap">LDAPCacheEntries</directive> and <directive
module="mod_ldap">LDAPCacheTTL</directive> directives.</p>
</section>
<section id="opcaches"><title>Operation Caches</title>
<p>During attribute and distinguished name comparison
functions, <module>mod_ldap</module> uses two operation caches
to cache the compare operations. The first compare cache is
used to cache the results of compares done to test for LDAP
group membership. The second compare cache is used to cache
the results of comparisons done between distinguished
names.</p>
<p>Note that, when group membership is being checked, any sub-group
comparison results are cached to speed future sub-group comparisons.</p>
<p>The behavior of both of these caches is controlled with
the <directive module="mod_ldap">LDAPOpCacheEntries</directive>
and <directive module="mod_ldap">LDAPOpCacheTTL</directive>
directives.</p>
</section>
<section id="monitoring"><title>Monitoring the Cache</title>
<p><module>mod_ldap</module> has a content handler that allows
administrators to monitor the cache performance. The name of
the content handler is <code>ldap-status</code>, so the
following directives could be used to access the
<module>mod_ldap</module> cache information:</p>
<example>
<indent>
SetHandler ldap-status<br />
</indent>
</Location>
</example>
the administrator can get a status report of every cache that is used
by <module>mod_ldap</module> cache. Note that if Apache does not
support shared memory, then each <program>httpd</program> instance has its
own cache, so reloading the URL will result in different
information each time, depending on which <program>httpd</program>
instance processes the request.</p>
</section>
</section>
<p>The ability to create an SSL and TLS connections to an LDAP server
is defined by the directives <directive module="mod_ldap">
LDAPTrustedGlobalCert</directive>, <directive module="mod_ldap">
LDAPTrustedClientCert</directive> and <directive module="mod_ldap">
LDAPTrustedMode</directive>. These directives specify the CA and
optional client certificates to be used, as well as the type of
<example>
# Establish an SSL LDAP connection on port 636. Requires that <br />
# mod_ldap and mod_authnz_ldap be loaded. Change the <br />
# "yourdomain.example.com" to match your domain.<br />
<br />
<br />
<Location /ldap-status><br />
<indent>
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
Satisfy any<br />
AuthType Basic<br />
AuthName "LDAP Protected"<br />
AuthBasicProvider ldap<br />
Require valid-user<br />
</indent>
</Location>
</example>
<example>
# Establish a TLS LDAP connection on port 389. Requires that <br />
# mod_ldap and mod_authnz_ldap be loaded. Change the <br />
# "yourdomain.example.com" to match your domain.<br />
<br />
<br />
<Location /ldap-status><br />
<indent>
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
Satisfy any<br />
AuthType Basic<br />
AuthName "LDAP Protected"<br />
AuthBasicProvider ldap<br />
Require valid-user<br />
</indent>
</Location>
</example>
</section>
<p>The different LDAP SDKs have widely different methods of setting
and handling both CA and client side certificates.</p>
<p>If you intend to use SSL or TLS, read this section CAREFULLY so as to
understand the differences between configurations on the different LDAP
toolkits supported.</p>
<p>CA certificates are specified within a file called cert7.db.
The SDK will not talk to any LDAP server whose certificate was
not signed by a CA specified in this file. If
client certificates are required, an optional key3.db file may
be specified with an optional password. The secmod file can be
specified if required. These files are in the same format as
used by the Netscape Communicator or Mozilla web browsers. The easiest
way to obtain these files is to grab them from your browser
installation.</p>
<p>Client certificates are specified per connection using the
LDAPTrustedClientCert directive by referring
to the certificate "nickname". An optional password may be
specified to unlock the certificate's private key.</p>
<p>The SDK supports SSL only. An attempt to use STARTTLS will cause
an error when an attempt is made to contact the LDAP server at
runtime.</p>
<example>
# Specify a Netscape CA certificate file<br />
# Specify an optional key3.db file for client certificate support<br />
# Specify the secmod file if required<br />
<Location /ldap-status><br />
<indent>
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
Satisfy any<br />
AuthType Basic<br />
AuthName "LDAP Protected"<br />
AuthBasicProvider ldap<br />
LDAPTrustedClientCert CERT_NICKNAME <nickname> [password]<br />
Require valid-user<br />
</indent>
</Location>
</example>
</section>
<section id="settingcerts-novell"><title>Novell SDK</title>
<p>One or more CA certificates must be specified for the Novell
SDK to work correctly. These certificates can be specified as
binary DER or Base64 (PEM) encoded files.</p>
<p>Note: Client certificates are specified globally rather than per
connection, and so must be specified with the LDAPTrustedGlobalCert
directive as below. Trying to set client certificates via the
LDAPTrustedClientCert directive will cause an error to be logged
when an attempt is made to connect to the LDAP server..</p>
<p>The SDK supports both SSL and STARTTLS, set using the
LDAPTrustedMode parameter. If an ldaps:// URL is specified,
SSL mode is forced, override this directive.</p>
<example>
# Specify two CA certificate files<br />
# Specify a client certificate file and key<br />
# Do not use this directive, as it will throw an error<br />
</example>
</section>
<section id="settingcerts-openldap"><title>OpenLDAP SDK</title>
<p>One or more CA certificates must be specified for the OpenLDAP
SDK to work correctly. These certificates can be specified as
binary DER or Base64 (PEM) encoded files.</p>
<p>Client certificates are specified per connection using the
LDAPTrustedClientCert directive.</p>
<p>The documentation for the SDK claims to support both SSL and
STARTTLS, however STARTTLS does not seem to work on all versions
LDAPTrustedMode parameter. If an ldaps:// URL is specified,
SSL mode is forced. The OpenLDAP documentation notes that SSL
(ldaps://) support has been deprecated to be replaced with TLS,
although the SSL functionality still works.</p>
<example>
# Specify two CA certificate files<br />
<Location /ldap-status><br />
<indent>
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
Satisfy any<br />
AuthType Basic<br />
AuthName "LDAP Protected"<br />
AuthBasicProvider ldap<br />
Require valid-user<br />
</indent>
</Location>
</example>
</section>
<section id="settingcerts-solaris"><title>Solaris SDK</title>
supported. If required, install and use the OpenLDAP libraries
instead.</p>
</section>
<section id="settingcerts-microsoft"><title>Microsoft SDK</title>
LDAP libraries is done inside the system registry, and no
configuration directives are required.</p>
<p>Both SSL and TLS are supported by using the ldaps:// URL
format, or by using the LDAPTrustedMode directive accordingly.</p>
<p>Note: The status of support for client certificates is not yet known
for this toolkit.</p>
</section>
</section>
<directivesynopsis>
<name>LDAPSharedCacheSize</name>
<description>Size in bytes of the shared-memory cache</description>
<syntax>LDAPSharedCacheSize <var>bytes</var></syntax>
<default>LDAPSharedCacheSize 500000</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the number of bytes to allocate for the shared
memory cache. The default is 500kb. If set to 0, shared memory
caching will not be used.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPSharedCacheFile</name>
<description>Sets the shared memory cache file</description>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the directory path and file name of the shared memory
cache file. If not set, anonymous shared memory will be used if the
platform supports it.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPCacheEntries</name>
<description>Maximum number of entries in the primary LDAP cache</description>
<syntax>LDAPCacheEntries <var>number</var></syntax>
<default>LDAPCacheEntries 1024</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the maximum size of the primary LDAP cache. This
searches.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPCacheTTL</name>
<description>Time that cached items remain valid</description>
<syntax>LDAPCacheTTL <var>seconds</var></syntax>
<default>LDAPCacheTTL 600</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the time (in seconds) that an item in the
minutes).</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPOpCacheEntries</name>
<description>Number of entries used to cache LDAP compare
operations</description>
<syntax>LDAPOpCacheEntries <var>number</var></syntax>
<default>LDAPOpCacheEntries 1024</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>This specifies the number of entries <module>mod_ldap</module>
will use to cache LDAP compare operations. The default is 1024
entries. Setting it to 0 disables operation caching.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPOpCacheTTL</name>
<description>Time that entries in the operation cache remain
valid</description>
<syntax>LDAPOpCacheTTL <var>seconds</var></syntax>
<default>LDAPOpCacheTTL 600</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the time (in seconds) that entries in the
operation cache remain valid. The default is 600 seconds.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPReferralHopLimit</name>
<description>The maximum number of referral hops to chase before terminating an LDAP query.</description>
<syntax>LDAPReferralHopLimit <var>number</var></syntax>
<default>LDAPReferralHopLimit 5</default>
<contextlist><context>directory</context><context>.htaccess</context></contextlist>
<override>AuthConfig</override>
<usage>
<p>This directive, if enabled by the <code>LDAPReferrals</code> directive,
limits the number of referral hops that are followed before terminating an
LDAP query.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPReferrals</name>
<description>Enable referral chasing during queries to the LDAP server.</description>
<syntax>LDAPReferrals <var>On|Off</var></syntax>
<default>LDAPReferrals On</default>
<contextlist><context>directory</context><context>.htaccess</context></contextlist>
<override>AuthConfig</override>
<usage>
<p>Some LDAP servers divide their directory among multiple domains and use referrals
to direct a client when a domain boundary is crossed. By setting <code>LDAPReferrals On</code>
referrals will be chased (setting it to off causes referrals to be ignored). The directive
<code>LDAPReferralHopLimit</code> works in conjunction with this directive to limit the
number of referral hops to follow before terminating the LDAP query. When referral processing
is enabled client credentials will be provided, via a rebind callback, for any LDAP server
requiring them. </p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPTrustedGlobalCert</name>
<description>Sets the file or database containing global trusted
Certificate Authority or global client certificates</description>
<syntax>LDAPTrustedGlobalCert <var>type</var> <var>directory-path/filename</var> <var>[password]</var></syntax>
<contextlist><context>server config</context></contextlist>
<usage>
<p>It specifies the directory path and file name of the trusted CA
should use when establishing an SSL or TLS connection to an LDAP
server. Note that all certificate information specified using this directive
is applied globally to the entire server installation. Some LDAP toolkits
(notably Novell) require all client certificates to be set globally using
this directive. Most other toolkits require clients certificates to be set
per Directory or per Location using LDAPTrustedClientCert. If you get this
wrong, an error may be logged when an attempt is made to contact the LDAP
guide above for details).
The type specifies the kind of certificate parameter being
set, depending on the LDAP toolkit being used. Supported types are:</p>
<ul>
<li>CA_DER - binary DER encoded CA certificate</li>
<li>CA_BASE64 - PEM encoded CA certificate</li>
<li>CA_SECMOD - Netscape secmod database file</li>
<li>CERT_DER - binary DER encoded client certificate</li>
<li>CERT_BASE64 - PEM encoded client certificate</li>
<li>CERT_NICKNAME - Client certificate "nickname" (Netscape SDK)</li>
<li>CERT_PFX - PKCS#12 encoded client certificate (Novell SDK)</li>
<li>KEY_DER - binary DER encoded private key</li>
<li>KEY_BASE64 - PEM encoded private key</li>
<li>KEY_PFX - PKCS#12 encoded private key (Novell SDK)</li>
</ul>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPTrustedClientCert</name>
<description>Sets the file containing or nickname referring to a per
connection client certificate. Not all LDAP toolkits support per
connection client certificates.</description>
<syntax>LDAPTrustedClientCert <var>type</var> <var>directory-path/filename/nickname</var> <var>[password]</var></syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context></contextlist>
<usage>
<p>It specifies the directory path, file name or nickname of a
per connection client certificate used when establishing an SSL
or TLS connection to an LDAP server. Different locations or
directories may have their own independant client certificate
settings. Some LDAP toolkits (notably Novell)
do not support per connection client certificates, and will throw an
error on LDAP server connection if you try to use this directive
(Use the LDAPTrustedGlobalCert directive instead for Novell client
The type specifies the kind of certificate parameter being
set, depending on the LDAP toolkit being used. Supported types are:</p>
<ul>
<li>CERT_DER - binary DER encoded client certificate</li>
<li>CERT_BASE64 - PEM encoded client certificate</li>
<li>CERT_NICKNAME - Client certificate "nickname" (Netscape SDK)</li>
<li>KEY_DER - binary DER encoded private key</li>
<li>KEY_BASE64 - PEM encoded private key</li>
</ul>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPTrustedMode</name>
<syntax>LDAPTrustedMode <var>type</var></syntax>
<contextlist><context>server config</context><context>virtual host</context></contextlist>
<usage>
<p>The following modes are supported:</p>
<ul>
<li>NONE - no encryption</li>
<li>SSL - ldaps:// encryption on default port 636</li>
<li>TLS - STARTTLS encryption on default port 389</li>
</ul>
<p>Not all LDAP toolkits support all the above modes. An error message
will be logged at runtime if a mode is not supported, and the
connection to the LDAP server will fail.
</p>
<p>If an ldaps:// URL is specified, the mode becomes SSL and the setting
of LDAPTrustedMode is ignored.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPConnectionTimeout</name>
<description>Specifies the socket connection timeout in seconds</description>
<syntax>LDAPConnectionTimeout <var>seconds</var></syntax>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies the timeout value (in seconds) in which the module will
attempt to connect to the LDAP server. If a connection is not
successful with the timeout period, either an error will be
returned or the module will attempt to connect to a secondary LDAP
server if one is specified. The default is 10 seconds.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>LDAPVerifyServerCert</name>
<description>Force server certificate verification</description>
<syntax>LDAPVerifyServerCert <var>On|Off</var></syntax>
<default>LDAPVerifyServerCert On</default>
<contextlist><context>server config</context></contextlist>
<usage>
<p>Specifies whether to force the verification of a
server certificate when establishing an SSL connection to the
LDAP server.</p>
</usage>
</directivesynopsis>
</modulesynopsis>