]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_authnz_ldap.xml
check: merge warning fixes from feature branch
[apache] / docs / manual / mod / mod_authnz_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 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <modulesynopsis metafile="mod_authnz_ldap.xml.meta">
24
25 <name>mod_authnz_ldap</name>
26 <description>Allows an LDAP directory to be used to store the database
27 for HTTP Basic authentication.</description>
28 <status>Extension</status>
29 <sourcefile>mod_authnz_ldap.c</sourcefile>
30 <identifier>authnz_ldap_module</identifier>
31
32 <summary>
33     <p>This module allows authentication front-ends such as
34     <module>mod_auth_basic</module> to authenticate users through
35     an ldap directory.</p>
36
37     <p><module>mod_authnz_ldap</module> supports the following features:</p>
38
39     <ul>
40       <li>Known to support the <a
41       href="http://www.openldap.org/">OpenLDAP SDK</a> (both 1.x
42       and 2.x), <a href="http://developer.novell.com/ndk/cldap.htm">
43       Novell LDAP SDK</a> and the <a
44       href="http://www.iplanet.com/downloads/developer/">iPlanet
45       (Netscape)</a> SDK.</li>
46
47       <li>Complex authorization policies can be implemented by
48       representing the policy with LDAP filters.</li>
49
50       <li>Uses extensive caching of LDAP operations via <a
51       href="mod_ldap.html">mod_ldap</a>.</li>
52
53       <li>Support for LDAP over SSL (requires the Netscape SDK) or
54       TLS (requires the OpenLDAP 2.x SDK or Novell LDAP SDK).</li>
55     </ul>
56
57     <p>When using <module>mod_auth_basic</module>, this module is invoked
58     via the <directive module="mod_auth_basic">AuthBasicProvider</directive>
59     directive with the <code>ldap</code> value.</p>
60 </summary>
61
62 <seealso><module>mod_ldap</module></seealso>
63 <seealso><module>mod_auth_basic</module></seealso>
64 <seealso><module>mod_authz_user</module></seealso>
65 <seealso><module>mod_authz_groupfile</module></seealso>
66
67 <section id="contents"><title>Contents</title>
68
69     <ul>
70       <li> <a href="#gcaveats">General caveats</a> </li>
71       <li> <a href="#operation">Operation</a>
72
73         <ul>
74           <li><a href="#authenphase">The Authentication
75           Phase</a></li>
76
77           <li><a href="#authorphase">The Authorization
78           Phase</a></li>
79         </ul>
80       </li>
81
82       <li>
83         <a href="#requiredirectives">The Require Directives</a>
84
85         <ul>
86           <li><a href="#requser">Require ldap-user</a></li>
87           <li><a href="#reqgroup">Require ldap-group</a></li>
88           <li><a href="#reqdn">Require ldap-dn</a></li>
89           <li><a href="#reqattribute">Require ldap-attribute</a></li>
90           <li><a href="#reqfilter">Require ldap-filter</a></li>
91           <li><a href="#reqsearch">Require ldap-search</a></li>
92         </ul>
93       </li>
94
95       <li><a href="#examples">Examples</a></li>
96       <li><a href="#usingtls">Using TLS</a></li>
97       <li><a href="#usingssl">Using SSL</a></li>
98       <li><a href="#exposed">Exposing Login Information</a></li>
99       <li><a href="#activedirectory">Using Active Directory</a></li>
100       <li>
101         <a href="#frontpage">Using Microsoft FrontPage with
102         <module>mod_authnz_ldap</module></a>
103
104         <ul>
105           <li><a href="#howitworks">How It Works</a></li>
106           <li><a href="#fpcaveats">Caveats</a></li>
107         </ul>
108       </li>
109     </ul>
110 </section>
111
112 <section id="gcaveats"><title>General caveats</title>
113 <p> This module caches authentication and authorization results based
114 on the configuration of <module>mod_ldap</module>. Changes
115 made to the backing LDAP server will not be immediately reflected on the
116 HTTP Server, including but not limited to user lockouts/revocations, 
117 password changes, or changes to group memberships.  Consult the directives 
118 in <module>mod_ldap</module> for details of the cache tunables.
119 </p>
120 </section>
121
122 <section id="operation"><title>Operation</title>
123
124     <p>There are two phases in granting access to a user. The first
125     phase is authentication, in which the <module>mod_authnz_ldap</module>
126     authentication provider verifies that the user's credentials are valid.
127     This is also called the <em>search/bind</em> phase. The second phase is
128     authorization, in which <module>mod_authnz_ldap</module> determines
129     if the authenticated user is allowed access to the resource in
130     question. This is also known as the <em>compare</em>
131     phase.</p>
132
133     <p><module>mod_authnz_ldap</module> registers both an authn_ldap authentication
134     provider and an authz_ldap authorization handler.  The authn_ldap
135     authentication provider can be enabled through the
136     <directive module="mod_auth_basic">AuthBasicProvider</directive> directive
137     using the <code>ldap</code> value. The authz_ldap handler extends the
138     <directive module="mod_authz_core">Require</directive> directive's authorization types
139     by adding <code>ldap-user</code>, <code>ldap-dn</code> and <code>ldap-group</code>
140     values.</p>
141
142 <section id="authenphase"><title>The Authentication
143     Phase</title>
144
145     <p>During the authentication phase, <module>mod_authnz_ldap</module>
146     searches for an entry in the directory that matches the username
147     that the HTTP client passes. If a single unique match is found,
148     then <module>mod_authnz_ldap</module> attempts to bind to the
149     directory server using the DN of the entry plus the password
150     provided by the HTTP client. Because it does a search, then a
151     bind, it is often referred to as the search/bind phase. Here are
152     the steps taken during the search/bind phase.</p>
153
154     <ol>
155       <li>Generate a search filter by combining the attribute and
156       filter provided in the <directive module="mod_authnz_ldap"
157       >AuthLDAPURL</directive> directive with
158       the username passed by the HTTP client.</li>
159
160       <li>Search the directory using the generated filter. If the
161       search does not return exactly one entry, deny or decline
162       access.</li>
163
164       <li>Fetch the distinguished name of the entry retrieved from
165       the search and attempt to bind to the LDAP server using that
166       DN and the password passed by the HTTP client. If the bind is
167       unsuccessful, deny or decline access.</li>
168     </ol>
169
170     <p>The following directives are used during the search/bind
171     phase</p>
172
173     <table>
174       <columnspec><column width=".3"/><column width=".7"/></columnspec>
175       <tr>
176         <td><directive module="mod_authnz_ldap">AuthLDAPURL</directive></td>
177
178         <td>Specifies the LDAP server, the
179         base DN, the attribute to use in the search, as well as the
180         extra search filter to use.</td>
181       </tr>
182
183       <tr>
184         <td><directive module="mod_authnz_ldap">AuthLDAPBindDN</directive></td>
185
186         <td>An optional DN to bind with
187         during the search phase.</td>
188       </tr>
189
190       <tr>
191         <td><directive
192         module="mod_authnz_ldap">AuthLDAPBindPassword</directive></td>
193
194         <td>An optional password to bind
195         with during the search phase.</td>
196       </tr>
197     </table>
198 </section>
199
200 <section id="authorphase"><title>The Authorization Phase</title>
201
202     <p>During the authorization phase, <module>mod_authnz_ldap</module>
203     attempts to determine if the user is authorized to access the
204     resource.  Many of these checks require
205     <module>mod_authnz_ldap</module> to do a compare operation on the
206     LDAP server. This is why this phase is often referred to as the
207     compare phase. <module>mod_authnz_ldap</module> accepts the
208     following <directive module="mod_authz_core">Require</directive>
209     directives to determine if the credentials are acceptable:</p>
210
211     <ul>
212       <li>Grant access if there is a <a
213       href="#reqgroup"><code>Require ldap-user</code></a> directive, and the
214       username in the directive matches the username passed by the
215       client.</li>
216
217       <li>Grant access if there is a <a href="#reqdn"><code>Require
218       ldap-dn</code></a> directive, and the DN in the directive matches
219       the DN fetched from the LDAP directory.</li>
220
221       <li>Grant access if there is a <a
222       href="#reqgroup"><code>Require ldap-group</code></a> directive, and
223       the DN fetched from the LDAP directory (or the username
224       passed by the client) occurs in the LDAP group or, potentially, in
225       one of its sub-groups.</li>
226
227       <li>Grant access if there is a <a href="#reqattribute">
228       <code>Require ldap-attribute</code></a>
229       directive, and the attribute fetched from the LDAP directory
230       matches the given value.</li>
231
232       <li>Grant access if there is a <a href="#reqfilter">
233       <code>Require ldap-filter</code></a>
234       directive, and the search filter successfully finds a single user
235       object that matches the dn of the authenticated user.</li>
236
237       <li>Grant access if there is a <a href="#reqsearch">
238       <code>Require ldap-search</code></a>
239       directive, and the search filter successfully returns a single
240       matching object with any distinguished name.</li>
241
242       <li>otherwise, deny or decline access</li>
243     </ul>
244
245     <p>Other <directive module="mod_authz_core">Require</directive> values may also
246     be used which may require loading additional authorization modules.</p>
247
248     <ul>
249         <li>Grant access to all successfully authenticated users if
250         there is a <a href="#requser"><code>Require valid-user</code></a>
251         directive. (requires <module>mod_authz_user</module>)</li>
252
253         <li>Grant access if there is a <a
254         href="#reqgroup"><code>Require group</code></a> directive, and
255         <module>mod_authz_groupfile</module> has been loaded with the
256         <directive module="mod_authz_groupfile">AuthGroupFile</directive>
257         directive set.</li>
258
259         <li>others...</li>
260      </ul>
261
262
263     <p><module>mod_authnz_ldap</module> uses the following directives during the
264     compare phase:</p>
265
266     <table>
267       <columnspec><column width=".4"/><column width=".6"/></columnspec>
268       <tr>
269         <td><directive module="mod_authnz_ldap">AuthLDAPURL</directive> </td>
270
271         <td>The attribute specified in the
272         URL is used in compare operations for the <code>Require
273         ldap-user</code> operation.</td>
274       </tr>
275
276       <tr>
277         <td><directive
278         module="mod_authnz_ldap">AuthLDAPCompareDNOnServer</directive></td>
279
280         <td>Determines the behavior of the
281         <code>Require ldap-dn</code> directive.</td>
282       </tr>
283
284       <tr>
285         <td><directive
286         module="mod_authnz_ldap">AuthLDAPGroupAttribute</directive></td>
287
288         <td>Determines the attribute to
289         use for comparisons in the <code>Require ldap-group</code>
290         directive.</td>
291       </tr>
292
293       <tr>
294         <td><directive
295         module="mod_authnz_ldap">AuthLDAPGroupAttributeIsDN</directive></td>
296
297         <td>Specifies whether to use the
298         user DN or the username when doing comparisons for the
299         <code>Require ldap-group</code> directive.</td>
300       </tr>
301
302       <tr>
303         <td><directive
304         module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive></td>
305
306         <td>Determines the maximum depth of sub-groups that will be evaluated
307         during comparisons in the <code>Require ldap-group</code> directive.</td>
308       </tr>
309
310       <tr>
311         <td><directive
312         module="mod_authnz_ldap">AuthLDAPSubGroupAttribute</directive></td>
313
314         <td>Determines the attribute to use when obtaining sub-group members
315         of the current group during comparisons in the <code>Require ldap-group</code>
316         directive.</td>
317       </tr>
318
319       <tr>
320         <td><directive
321         module="mod_authnz_ldap">AuthLDAPSubGroupClass</directive></td>
322
323         <td>Specifies the LDAP objectClass values used to identify if queried directory
324         objects really are group objects (as opposed to user objects) during the
325         <code>Require ldap-group</code> directive's sub-group processing.</td>
326       </tr>
327     </table>
328 </section>
329 </section>
330
331 <section id="requiredirectives"><title>The Require Directives</title>
332
333     <p>Apache's <directive module="mod_authz_core">Require</directive>
334     directives are used during the authorization phase to ensure that
335     a user is allowed to access a resource.  mod_authnz_ldap extends the
336     authorization types with <code>ldap-user</code>, <code>ldap-dn</code>,
337     <code>ldap-group</code>, <code>ldap-attribute</code> and
338     <code>ldap-filter</code>.  Other authorization types may also be
339     used but may require that additional authorization modules be loaded.</p>
340
341     <p>Since v2.4.8, <a href="../expr.html">expressions</a> are supported
342     within the LDAP require directives.</p>
343
344 <section id="requser"><title>Require ldap-user</title>
345
346     <p>The <code>Require ldap-user</code> directive specifies what
347     usernames can access the resource. Once
348     <module>mod_authnz_ldap</module> has retrieved a unique DN from the
349     directory, it does an LDAP compare operation using the username
350     specified in the <code>Require ldap-user</code> to see if that username
351     is part of the just-fetched LDAP entry.  Multiple users can be
352     granted access by putting multiple usernames on the line,
353     separated with spaces. If a username has a space in it, then it
354     must be surrounded with double quotes. Multiple users can also be
355     granted access by using multiple <code>Require ldap-user</code>
356     directives, with one user per line. For example, with a <directive
357     module="mod_authnz_ldap">AuthLDAPURL</directive> of
358     <code>ldap://ldap/o=Example?cn</code> (i.e., <code>cn</code> is
359     used for searches), the following Require directives could be used
360     to restrict access:</p>
361 <highlight language="config">
362 Require ldap-user "Barbara Jenson"
363 Require ldap-user "Fred User"
364 Require ldap-user "Joe Manager"
365 </highlight>
366
367     <p>Because of the way that <module>mod_authnz_ldap</module> handles this
368     directive, Barbara Jenson could sign on as <em>Barbara
369     Jenson</em>, <em>Babs Jenson</em> or any other <code>cn</code> that
370     she has in her LDAP entry. Only the single <code>Require
371     ldap-user</code> line is needed to support all values of the attribute
372     in the user's entry.</p>
373
374     <p>If the <code>uid</code> attribute was used instead of the
375     <code>cn</code> attribute in the URL above, the above three lines
376     could be condensed to</p>
377 <highlight language="config">
378 Require ldap-user bjenson fuser jmanager
379 </highlight>
380 </section>
381
382 <section id="reqgroup"><title>Require ldap-group</title>
383
384     <p>This directive specifies an LDAP group whose members are
385     allowed access. It takes the distinguished name of the LDAP
386     group. Note: Do not surround the group name with quotes.
387     For example, assume that the following entry existed in
388     the LDAP directory:</p>
389 <example><pre>
390 dn: cn=Administrators, o=Example
391 objectClass: groupOfUniqueNames
392 uniqueMember: cn=Barbara Jenson, o=Example
393 uniqueMember: cn=Fred User, o=Example
394 </pre></example>
395
396     <p>The following directive would grant access to both Fred and
397     Barbara:</p>
398 <highlight language="config">
399 Require ldap-group cn=Administrators, o=Example
400 </highlight>
401
402     <p>Members can also be found within sub-groups of a specified LDAP group
403     if <directive module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive>
404     is set to a value greater than 0. For example, assume the following entries
405     exist in the LDAP directory:</p>
406 <example><pre>
407 dn: cn=Employees, o=Example
408 objectClass: groupOfUniqueNames
409 uniqueMember: cn=Managers, o=Example
410 uniqueMember: cn=Administrators, o=Example
411 uniqueMember: cn=Users, o=Example
412
413 dn: cn=Managers, o=Example
414 objectClass: groupOfUniqueNames
415 uniqueMember: cn=Bob Ellis, o=Example
416 uniqueMember: cn=Tom Jackson, o=Example
417
418 dn: cn=Administrators, o=Example
419 objectClass: groupOfUniqueNames
420 uniqueMember: cn=Barbara Jenson, o=Example
421 uniqueMember: cn=Fred User, o=Example
422
423 dn: cn=Users, o=Example
424 objectClass: groupOfUniqueNames
425 uniqueMember: cn=Allan Jefferson, o=Example
426 uniqueMember: cn=Paul Tilley, o=Example
427 uniqueMember: cn=Temporary Employees, o=Example
428
429 dn: cn=Temporary Employees, o=Example
430 objectClass: groupOfUniqueNames
431 uniqueMember: cn=Jim Swenson, o=Example
432 uniqueMember: cn=Elliot Rhodes, o=Example
433 </pre></example>
434
435     <p>The following directives would allow access for Bob Ellis, Tom Jackson,
436     Barbara Jenson, Fred User, Allan Jefferson, and Paul Tilley but would not
437     allow access for Jim Swenson, or Elliot Rhodes (since they are at a
438     sub-group depth of 2):</p>
439 <highlight language="config">
440 Require ldap-group cn=Employees, o=Example
441 AuthLDAPMaxSubGroupDepth 1
442 </highlight>
443
444     <p>Behavior of this directive is modified by the <directive
445     module="mod_authnz_ldap">AuthLDAPGroupAttribute</directive>, <directive
446     module="mod_authnz_ldap">AuthLDAPGroupAttributeIsDN</directive>, <directive
447     module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive>, <directive
448     module="mod_authnz_ldap">AuthLDAPSubGroupAttribute</directive>, and <directive
449     module="mod_authnz_ldap">AuthLDAPSubGroupClass</directive>
450     directives.</p>
451 </section>
452
453 <section id="reqdn"><title>Require ldap-dn</title>
454
455     <p>The <code>Require ldap-dn</code> directive allows the administrator
456     to grant access based on distinguished names. It specifies a DN
457     that must match for access to be granted. If the distinguished
458     name that was retrieved from the directory server matches the
459     distinguished name in the <code>Require ldap-dn</code>, then
460     authorization is granted. Note: do not surround the distinguished
461     name with quotes.</p>
462
463     <p>The following directive would grant access to a specific
464     DN:</p>
465 <highlight language="config">
466 Require ldap-dn cn=Barbara Jenson, o=Example
467 </highlight>
468
469     <p>Behavior of this directive is modified by the <directive
470     module="mod_authnz_ldap">AuthLDAPCompareDNOnServer</directive>
471     directive.</p>
472 </section>
473
474 <section id="reqattribute"><title>Require ldap-attribute</title>
475
476     <p>The <code>Require ldap-attribute</code> directive allows the
477     administrator to grant access based on attributes of the authenticated
478     user in the LDAP directory.  If the attribute in the directory
479     matches the value given in the configuration, access is granted.</p>
480
481     <p>The following directive would grant access to anyone with
482     the attribute employeeType = active</p>
483
484     <highlight language="config">
485 Require ldap-attribute "employeeType=active"
486 </highlight>
487
488     <p>Multiple attribute/value pairs can be specified on the same line
489     separated by spaces or they can be specified in multiple
490     <code>Require ldap-attribute</code> directives. The effect of listing
491     multiple attribute/values pairs is an OR operation. Access will be
492     granted if any of the listed attribute values match the value of the
493     corresponding attribute in the user object. If the value of the
494     attribute contains a space, only the value must be within double quotes.</p>
495
496     <p>The following directive would grant access to anyone with
497     the city attribute equal to "San Jose" or status equal to "Active"</p>
498
499     <highlight language="config">
500 Require ldap-attribute city="San Jose" "status=active"
501 </highlight>
502
503 </section>
504
505 <section id="reqfilter"><title>Require ldap-filter</title>
506
507     <p>The <code>Require ldap-filter</code> directive allows the
508     administrator to grant access based on a complex LDAP search filter.
509     If the dn returned by the filter search matches the authenticated user
510     dn, access is granted.</p>
511
512     <p>The following directive would grant access to anyone having a cell phone
513     and is in the marketing department</p>
514
515     <highlight language="config">
516 Require ldap-filter "&amp;(cell=*)(department=marketing)"
517 </highlight>
518
519     <p>The difference between the <code>Require ldap-filter</code> directive and the
520     <code>Require ldap-attribute</code> directive is that <code>ldap-filter</code>
521     performs a search operation on the LDAP directory using the specified search
522     filter rather than a simple attribute comparison. If a simple attribute
523     comparison is all that is required, the comparison operation performed by
524     <code>ldap-attribute</code> will be faster than the search operation
525     used by <code>ldap-filter</code> especially within a large directory.</p>
526
527     <p>When using an <a href="../expr.html">expression</a> within the filter, care
528     must be taken to ensure that LDAP filters are escaped correctly to guard against
529     LDAP injection. The ldap function can be used for this purpose.</p>
530
531 <highlight language="config">
532 &lt;LocationMatch "^/dav/(?&lt;SITENAME&gt;[^/]+)/"&gt;
533   Require ldap-filter "(memberOf=cn=%{ldap:%{unescape:%{env:MATCH_SITENAME}},ou=Websites,o=Example)"
534 &lt;/LocationMatch&gt;
535 </highlight>
536
537 </section>
538
539 <section id="reqsearch"><title>Require ldap-search</title>
540
541     <p>The <code>Require ldap-search</code> directive allows the
542     administrator to grant access based on a generic LDAP search filter using an
543     <a href="../expr.html">expression</a>. If there is exactly one match to the search filter,
544     regardless of the distinguished name, access is granted.</p>
545
546     <p>The following directive would grant access to URLs that match the given objects in the
547     LDAP server:</p>
548
549 <highlight language="config">
550 &lt;LocationMatch "^/dav/(?&lt;SITENAME&gt;[^/]+)/"&gt;
551 Require ldap-search "(cn=%{ldap:%{unescape:%{env:MATCH_SITENAME}} Website)"
552 &lt;/LocationMatch&gt;
553 </highlight>
554
555     <p>Note: care must be taken to ensure that any expressions are properly escaped to guard
556     against LDAP injection. The <strong>ldap</strong> function can be used as per the example
557     above.</p>
558
559 </section>
560
561 </section>
562
563 <section id="examples"><title>Examples</title>
564
565     <ul>
566       <li>
567         Grant access to anyone who exists in the LDAP directory,
568         using their UID for searches.
569 <highlight language="config">
570 AuthLDAPURL "ldap://ldap1.example.com:389/ou=People, o=Example?uid?sub?(objectClass=*)"
571 Require valid-user
572 </highlight>
573       </li>
574
575       <li>
576         The next example is the same as above; but with the fields
577         that have useful defaults omitted. Also, note the use of a
578         redundant LDAP server.
579 <highlight language="config">
580 AuthLDAPURL "ldap://ldap1.example.com ldap2.example.com/ou=People, o=Example"
581 Require valid-user
582 </highlight>
583       </li>
584
585       <li>
586         The next example is similar to the previous one, but it
587         uses the common name instead of the UID. Note that this
588         could be problematical if multiple people in the directory
589         share the same <code>cn</code>, because a search on <code>cn</code>
590         <strong>must</strong> return exactly one entry. That's why
591         this approach is not recommended: it's a better idea to
592         choose an attribute that is guaranteed unique in your
593         directory, such as <code>uid</code>.
594 <highlight language="config">
595 AuthLDAPURL "ldap://ldap.example.com/ou=People, o=Example?cn"
596 Require valid-user
597 </highlight>
598       </li>
599
600       <li>
601         Grant access to anybody in the Administrators group. The
602         users must authenticate using their UID.
603 <highlight language="config">
604 AuthLDAPURL ldap://ldap.example.com/o=Example?uid
605 Require ldap-group cn=Administrators, o=Example
606 </highlight>
607       </li>
608
609       <li>
610         Grant access to anybody in the group whose name matches the
611         hostname of the virtual host. In this example an
612         <a href="../expr.html">expression</a> is used to build the filter.
613 <highlight language="config">
614 AuthLDAPURL ldap://ldap.example.com/o=Example?uid
615 Require ldap-group cn=%{SERVER_NAME}, o=Example
616 </highlight>
617       </li>
618
619       <li>
620         The next example assumes that everyone at Example who
621         carries an alphanumeric pager will have an LDAP attribute
622         of <code>qpagePagerID</code>. The example will grant access
623         only to people (authenticated via their UID) who have
624         alphanumeric pagers:
625 <highlight language="config">
626 AuthLDAPURL ldap://ldap.example.com/o=Example?uid??(qpagePagerID=*)
627 Require valid-user
628 </highlight>
629       </li>
630
631       <li>
632         <p>The next example demonstrates the power of using filters
633         to accomplish complicated administrative requirements.
634         Without filters, it would have been necessary to create a
635         new LDAP group and ensure that the group's members remain
636         synchronized with the pager users. This becomes trivial
637         with filters. The goal is to grant access to anyone who has
638         a pager, plus grant access to Joe Manager, who doesn't
639         have a pager, but does need to access the same
640         resource:</p>
641 <highlight language="config">
642 AuthLDAPURL ldap://ldap.example.com/o=Example?uid??(|(qpagePagerID=*)(uid=jmanager))
643 Require valid-user
644 </highlight>
645
646         <p>This last may look confusing at first, so it helps to
647         evaluate what the search filter will look like based on who
648         connects, as shown below.  If
649         Fred User connects as <code>fuser</code>, the filter would look
650         like</p>
651
652         <example>(&amp;(|(qpagePagerID=*)(uid=jmanager))(uid=fuser))</example>
653
654         <p>The above search will only succeed if <em>fuser</em> has a
655         pager. When Joe Manager connects as <em>jmanager</em>, the
656         filter looks like</p>
657
658         <example>(&amp;(|(qpagePagerID=*)(uid=jmanager))(uid=jmanager))</example>
659
660         <p>The above search will succeed whether <em>jmanager</em>
661         has a pager or not.</p>
662       </li>
663     </ul>
664 </section>
665
666 <section id="usingtls"><title>Using TLS</title>
667
668     <p>To use TLS, see the <module>mod_ldap</module> directives <directive
669     module="mod_ldap">LDAPTrustedClientCert</directive>, <directive
670     module="mod_ldap">LDAPTrustedGlobalCert</directive> and <directive
671     module="mod_ldap">LDAPTrustedMode</directive>.</p>
672
673     <p>An optional second parameter can be added to the
674     <directive module="mod_authnz_ldap">AuthLDAPURL</directive> to override
675     the default connection type set by <directive module="mod_ldap">LDAPTrustedMode</directive>.
676     This will allow the connection established by an <em>ldap://</em> Url
677     to be upgraded to a secure connection on the same port.</p>
678 </section>
679
680 <section id="usingssl"><title>Using SSL</title>
681
682     <p>To use SSL, see the <module>mod_ldap</module> directives <directive
683     module="mod_ldap">LDAPTrustedClientCert</directive>, <directive
684     module="mod_ldap">LDAPTrustedGlobalCert</directive> and <directive
685     module="mod_ldap">LDAPTrustedMode</directive>.</p>
686
687     <p>To specify a secure LDAP server, use <em>ldaps://</em> in the
688     <directive module="mod_authnz_ldap">AuthLDAPURL</directive>
689     directive, instead of <em>ldap://</em>.</p>
690 </section>
691
692 <section id="exposed"><title>Exposing Login Information</title>
693
694     <p>when this module performs <em>authentication</em>, ldap attributes specified
695     in the <directive module="mod_authnz_ldap">authldapurl</directive>
696     directive are placed in environment variables with the prefix "AUTHENTICATE_".</p>
697
698     <p>when this module performs <em>authorization</em>, ldap attributes specified
699     in the <directive module="mod_authnz_ldap">authldapurl</directive>
700     directive are placed in environment variables with the prefix "AUTHORIZE_".</p>
701
702     <p>If the attribute field contains the username, common name
703     and telephone number of a user, a CGI program will have access to
704     this information without the need to make a second independent LDAP
705     query to gather this additional information.</p>
706
707     <p>This has the potential to dramatically simplify the coding and
708     configuration required in some web applications.</p>
709
710 </section>
711
712 <section id="activedirectory"><title>Using Active Directory</title>
713
714     <p>An Active Directory installation may support multiple domains at the
715     same time. To distinguish users between domains, an identifier called
716     a User Principle Name (UPN) can be added to a user's entry in the
717     directory. This UPN usually takes the form of the user's account
718     name, followed by the domain components of the particular domain,
719     for example <em>somebody@nz.example.com</em>.</p>
720
721     <p>You may wish to configure the <module>mod_authnz_ldap</module>
722     module to authenticate users present in any of the domains making up
723     the Active Directory forest. In this way both
724     <em>somebody@nz.example.com</em> and <em>someone@au.example.com</em>
725     can be authenticated using the same query at the same time.</p>
726
727     <p>To make this practical, Active Directory supports the concept of
728     a Global Catalog. This Global Catalog is a read only copy of selected
729     attributes of all the Active Directory servers within the Active
730     Directory forest. Querying the Global Catalog allows all the domains
731     to be queried in a single query, without the query spanning servers
732     over potentially slow links.</p>
733
734     <p>If enabled, the Global Catalog is an independent directory server
735     that runs on port 3268 (3269 for SSL). To search for a user, do a
736     subtree search for the attribute <em>userPrincipalName</em>, with
737     an empty search root, like so:</p>
738
739 <highlight language="config">
740 AuthLDAPBindDN apache@example.com
741 AuthLDAPBindPassword password
742 AuthLDAPURL ldap://10.0.0.1:3268/?userPrincipalName?sub
743 </highlight>
744
745     <p>Users will need to enter their User Principal Name as a login, in
746     the form <em>somebody@nz.example.com</em>.</p>
747
748 </section>
749
750 <section id="frontpage"><title>Using Microsoft
751     FrontPage with mod_authnz_ldap</title>
752
753     <p>Normally, FrontPage uses FrontPage-web-specific user/group
754     files (i.e., the <module>mod_authn_file</module> and
755     <module>mod_authz_groupfile</module> modules) to handle all
756     authentication. Unfortunately, it is not possible to just
757     change to LDAP authentication by adding the proper directives,
758     because it will break the <em>Permissions</em> forms in
759     the FrontPage client, which attempt to modify the standard
760     text-based authorization files.</p>
761
762     <p>Once a FrontPage web has been created, adding LDAP
763     authentication to it is a matter of adding the following
764     directives to <em>every</em> <code>.htaccess</code> file
765     that gets created in the web</p>
766 <highlight language="config">
767 AuthLDAPURL       "the url"
768 AuthGroupFile     "mygroupfile"
769 Require group     "mygroupfile"
770 </highlight>
771
772 <section id="howitworks"><title>How It Works</title>
773
774     <p>FrontPage restricts access to a web by adding the <code>Require
775     valid-user</code> directive to the <code>.htaccess</code>
776     files. The <code>Require valid-user</code> directive will succeed for
777     any user who is valid <em>as far as LDAP is
778     concerned</em>. This means that anybody who has an entry in
779     the LDAP directory is considered a valid user, whereas FrontPage
780     considers only those people in the local user file to be
781     valid. By substituting the ldap-group with group file authorization,
782     Apache is allowed to consult the local user file (which is managed by
783     FrontPage) - instead of LDAP - when handling authorizing the user.</p>
784
785     <p>Once directives have been added as specified above,
786     FrontPage users will be able to perform all management
787     operations from the FrontPage client.</p>
788 </section>
789
790 <section id="fpcaveats"><title>Caveats</title>
791
792     <ul>
793       <li>When choosing the LDAP URL, the attribute to use for
794       authentication should be something that will also be valid
795       for putting into a <module>mod_authn_file</module> user file.
796       The user ID is ideal for this.</li>
797
798       <li>When adding users via FrontPage, FrontPage administrators
799       should choose usernames that already exist in the LDAP
800       directory (for obvious reasons). Also, the password that the
801       administrator enters into the form is ignored, since Apache
802       will actually be authenticating against the password in the
803       LDAP database, and not against the password in the local user
804       file. This could cause confusion for web administrators.</li>
805
806       <!-- XXX is that true? was mod_auth before the aaa change -->
807       <li>Apache must be compiled with <module>mod_auth_basic</module>,
808       <module>mod_authn_file</module> and
809       <module>mod_authz_groupfile</module> in order to
810       use FrontPage support. This is because Apache will still use
811       the <module>mod_authz_groupfile</module> group file for determine
812       the extent of a user's access to the FrontPage web.</li>
813
814       <li>The directives must be put in the <code>.htaccess</code>
815       files. Attempting to put them inside <directive module="core"
816       type="section">Location</directive> or <directive module="core"
817       type="section">Directory</directive> directives won't work. This
818       is because <module>mod_authnz_ldap</module> has to be able to grab
819       the <directive module="mod_authz_groupfile">AuthGroupFile</directive>
820       directive that is found in FrontPage <code>.htaccess</code>
821       files so that it knows where to look for the valid user list. If
822       the <module>mod_authnz_ldap</module> directives aren't in the same
823       <code>.htaccess</code> file as the FrontPage directives, then
824       the hack won't work, because <module>mod_authnz_ldap</module> will
825       never get a chance to process the <code>.htaccess</code> file,
826       and won't be able to find the FrontPage-managed user file.</li>
827     </ul>
828 </section>
829 </section>
830
831 <directivesynopsis>
832 <name>AuthLDAPAuthorizePrefix</name>
833 <description>Specifies the prefix for environment variables set during
834 authorization</description>
835 <syntax>AuthLDAPAuthorizePrefix <em>prefix</em></syntax>
836 <default>AuthLDAPAuthorizePrefix AUTHORIZE_</default>
837 <contextlist><context>directory</context><context>.htaccess</context>
838 </contextlist>
839 <override>AuthConfig</override>
840 <compatibility>Available in version 2.3.6 and later</compatibility>
841 <usage>
842     <p>This directive allows you to override the prefix used for environment
843     variables set during LDAP authorization.  If <em>AUTHENTICATE_</em> is
844     specified, consumers of these environment variables see the same information
845     whether LDAP has performed authentication, authorization, or both.</p>
846
847     <note><title>Note</title>
848     No authorization variables are set when a user is authorized on the basis of
849     <code>Require valid-user</code>.
850     </note>
851 </usage>
852 </directivesynopsis>
853
854
855 <directivesynopsis>
856 <name>AuthLDAPBindAuthoritative</name>
857 <description>Determines if other authentication providers are used when a user can be mapped to a DN but the server cannot successfully bind with the user's credentials.</description>
858 <syntax>AuthLDAPBindAuthoritative off|on</syntax>
859 <default>AuthLDAPBindAuthoritative on</default>
860 <contextlist><context>directory</context><context>.htaccess</context>
861 </contextlist>
862 <override>AuthConfig</override>
863 <usage>
864     <p>By default, subsequent authentication providers are only queried if a
865     user cannot be mapped to a DN, but not if the user can be mapped to a DN and their
866     password cannot be verified with an LDAP bind.
867     If <directive>AuthLDAPBindAuthoritative</directive>
868     is set to <em>off</em>, other configured authentication modules will have
869     a chance to validate the user if the LDAP bind (with the current user's credentials)
870     fails for any reason.</p>
871     <p> This allows users present in both LDAP and
872     <directive module="mod_authn_file">AuthUserFile</directive> to authenticate
873     when the LDAP server is available but the user's account is locked or password
874     is otherwise unusable.</p>
875 </usage>
876 <seealso><directive module="mod_authn_file">AuthUserFile</directive></seealso>
877 <seealso><directive module="mod_auth_basic">AuthBasicProvider</directive></seealso>
878 </directivesynopsis>
879
880 <directivesynopsis>
881 <name>AuthLDAPInitialBindAsUser</name>
882 <description>Determines if the server does the initial DN lookup using the basic authentication users'
883 own username, instead of anonymously or with hard-coded credentials for the server</description>
884 <syntax>AuthLDAPInitialBindAsUser off|on</syntax>
885 <default>AuthLDAPInitialBindAsUser off</default>
886 <contextlist><context>directory</context><context>.htaccess</context>
887 </contextlist>
888 <override>AuthConfig</override>
889 <compatibility>Available in version 2.3.6 and later</compatibility>
890 <usage>
891     <p>By default, the server either anonymously, or with a dedicated user and
892      password, converts the basic authentication username into an LDAP
893      distinguished name (DN).  This directive forces the server to use the verbatim username
894      and password provided by the incoming user to perform the initial DN
895      search.</p>
896
897      <p> If the verbatim username can't directly bind, but needs some
898      cosmetic transformation, see <directive module="mod_authnz_ldap">
899      AuthLDAPInitialBindPattern</directive>.</p>
900
901      <p> This directive should only be used when your LDAP server doesn't
902          accept anonymous searches and you cannot use a dedicated
903          <directive module="mod_authnz_ldap">AuthLDAPBindDN</directive>.
904      </p>
905
906      <note><title>Not available with authorization-only</title>
907          This directive can only be used if this module authenticates the user, and
908          has no effect when this module is used exclusively for authorization.
909      </note>
910 </usage>
911 <seealso><directive module="mod_authnz_ldap">AuthLDAPInitialBindPattern</directive></seealso>
912 <seealso><directive module="mod_authnz_ldap">AuthLDAPBindDN</directive></seealso>
913 <seealso><directive module="mod_authnz_ldap">AuthLDAPCompareAsUser</directive></seealso>
914 <seealso><directive module="mod_authnz_ldap">AuthLDAPSearchAsUser</directive></seealso>
915 </directivesynopsis>
916
917 <directivesynopsis>
918 <name>AuthLDAPInitialBindPattern</name>
919 <description>Specifies the transformation of the basic authentication username to be used when binding to the LDAP server
920 to perform a DN lookup</description>
921 <syntax>AuthLDAPInitialBindPattern <em><var>regex</var> <var>substitution</var></em></syntax>
922 <default>AuthLDAPInitialBindPattern (.*) $1 (remote username used verbatim)</default>
923 <contextlist><context>directory</context><context>.htaccess</context>
924 </contextlist>
925 <override>AuthConfig</override>
926 <compatibility>Available in version 2.3.6 and later</compatibility>
927 <usage>
928     <p>If <directive module="mod_authnz_ldap">AuthLDAPInitialBindAsUser</directive> is set to
929        <em>ON</em>, the basic authentication username will be transformed according to the
930        regular expression and substitution arguments.</p>
931
932     <p> The regular expression argument is compared against the current basic authentication username.
933         The substitution argument may contain backreferences, but has no other variable interpolation.</p>
934
935     <p> This directive should only be used when your LDAP server doesn't
936         accept anonymous searches and you cannot use a dedicated
937         <directive module="mod_authnz_ldap">AuthLDAPBindDN</directive>.
938     </p>
939
940     <highlight language="config">
941 AuthLDAPInitialBindPattern (.+) $1@example.com
942     </highlight>
943     <highlight language="config">
944 AuthLDAPInitialBindPattern (.+) cn=$1,dc=example,dc=com
945     </highlight>
946
947     <note><title>Not available with authorization-only</title>
948         This directive can only be used if this module authenticates the user, and
949         has no effect when this module is used exclusively for authorization.
950     </note>
951     <note><title>debugging</title>
952         The substituted DN is recorded in the environment variable
953         <em>LDAP_BINDASUSER</em>.  If the regular expression does not match the input,
954         the verbatim username is used.
955     </note>
956 </usage>
957 <seealso><directive module="mod_authnz_ldap">AuthLDAPInitialBindAsUser</directive></seealso>
958 <seealso><directive module="mod_authnz_ldap">AuthLDAPBindDN</directive></seealso>
959 </directivesynopsis>
960
961 <directivesynopsis>
962 <name>AuthLDAPBindDN</name>
963 <description>Optional DN to use in binding to the LDAP server</description>
964 <syntax>AuthLDAPBindDN <em>distinguished-name</em></syntax>
965 <contextlist><context>directory</context><context>.htaccess</context>
966 </contextlist>
967 <override>AuthConfig</override>
968
969 <usage>
970     <p>An optional DN used to bind to the server when searching for
971     entries. If not provided, <module>mod_authnz_ldap</module> will use
972     an anonymous bind.</p>
973 </usage>
974 </directivesynopsis>
975
976 <directivesynopsis>
977 <name>AuthLDAPBindPassword</name>
978 <description>Password used in conjunction with the bind DN</description>
979 <syntax>AuthLDAPBindPassword <em>password</em></syntax>
980 <contextlist><context>directory</context><context>.htaccess</context>
981 </contextlist>
982 <override>AuthConfig</override>
983 <compatibility><em>exec:</em> was added in 2.4.5.</compatibility>
984
985 <usage>
986     <p>A bind password to use in conjunction with the bind DN. Note
987     that the bind password is probably sensitive data, and should be
988     properly protected. You should only use the <directive
989     module="mod_authnz_ldap">AuthLDAPBindDN</directive> and <directive
990     >AuthLDAPBindPassword</directive> if you
991     absolutely need them to search the directory.</p>
992
993     <p>If the value begins with exec: the resulting command will be
994     executed and the first line returned to standard output by the
995     program will be used as the password.</p>
996 <highlight language="config">
997 #Password used as-is
998 AuthLDAPBindPassword secret
999
1000 #Run /path/to/program to get my password
1001 AuthLDAPBindPassword exec:/path/to/program
1002
1003 #Run /path/to/otherProgram and provide arguments
1004 AuthLDAPBindPassword "exec:/path/to/otherProgram argument1"
1005 </highlight>
1006
1007 </usage>
1008 </directivesynopsis>
1009
1010 <directivesynopsis>
1011 <name>AuthLDAPCharsetConfig</name>
1012 <description>Language to charset conversion configuration file</description>
1013 <syntax>AuthLDAPCharsetConfig <em>file-path</em></syntax>
1014 <contextlist><context>server config</context>
1015 </contextlist>
1016
1017 <usage>
1018     <p>The <directive>AuthLDAPCharsetConfig</directive> directive sets the location
1019     of the language to charset conversion configuration file. <var>File-path</var> is relative
1020     to the <directive module="core">ServerRoot</directive>. This file specifies
1021     the list of language extensions to character sets.
1022     Most administrators use the provided <code>charset.conv</code>
1023     file, which associates common language extensions to character sets.</p>
1024
1025     <p>The file contains lines in the following format:</p>
1026
1027     <example>
1028       <var>Language-Extension</var> <var>charset</var> [<var>Language-String</var>] ...
1029     </example>
1030
1031     <p>The case of the extension does not matter. Blank lines, and lines
1032     beginning with a hash character (<code>#</code>) are ignored.</p>
1033 </usage>
1034 </directivesynopsis>
1035
1036 <directivesynopsis>
1037 <name>AuthLDAPCompareAsUser</name>
1038 <description>Use the authenticated user's credentials to perform authorization comparisons</description>
1039 <syntax>AuthLDAPCompareAsUser on|off</syntax>
1040 <default>AuthLDAPCompareAsUser off</default>
1041 <contextlist><context>directory</context><context>.htaccess</context>
1042 </contextlist>
1043 <override>AuthConfig</override>
1044 <compatibility>Available in version 2.3.6 and later</compatibility>
1045
1046 <usage>
1047     <p>When set, and <module>mod_authnz_ldap</module> has authenticated the
1048     user, LDAP comparisons for authorization use the queried distinguished name (DN)
1049     and HTTP basic authentication password of the authenticated user instead of
1050     the servers configured credentials.</p>
1051
1052     <p> The <em>ldap-attribute</em>, <em>ldap-user</em>, and <em>ldap-group</em> (single-level only)
1053     authorization checks use comparisons.</p>
1054
1055     <p>This directive only has effect on the comparisons performed during
1056     nested group processing when <directive module="mod_authnz_ldap">
1057     AuthLDAPSearchAsUser</directive> is also enabled.</p>
1058
1059     <p> This directive should only be used when your LDAP server doesn't
1060         accept anonymous comparisons and you cannot use a dedicated
1061         <directive module="mod_authnz_ldap">AuthLDAPBindDN</directive>.
1062     </p>
1063 </usage>
1064 <seealso><directive module="mod_authnz_ldap">AuthLDAPInitialBindAsUser</directive></seealso>
1065 <seealso><directive module="mod_authnz_ldap">AuthLDAPSearchAsUser</directive></seealso>
1066 </directivesynopsis>
1067
1068 <directivesynopsis>
1069 <name>AuthLDAPCompareDNOnServer</name>
1070 <description>Use the LDAP server to compare the DNs</description>
1071 <syntax>AuthLDAPCompareDNOnServer on|off</syntax>
1072 <default>AuthLDAPCompareDNOnServer on</default>
1073 <contextlist><context>directory</context><context>.htaccess</context>
1074 </contextlist>
1075 <override>AuthConfig</override>
1076
1077 <usage>
1078     <p>When set, <module>mod_authnz_ldap</module> will use the LDAP
1079     server to compare the DNs. This is the only foolproof way to
1080     compare DNs.  <module>mod_authnz_ldap</module> will search the
1081     directory for the DN specified with the <a
1082     href="#reqdn"><code>Require dn</code></a> directive, then,
1083     retrieve the DN and compare it with the DN retrieved from the user
1084     entry. If this directive is not set,
1085     <module>mod_authnz_ldap</module> simply does a string comparison. It
1086     is possible to get false negatives with this approach, but it is
1087     much faster. Note the <module>mod_ldap</module> cache can speed up
1088     DN comparison in most situations.</p>
1089 </usage>
1090 </directivesynopsis>
1091
1092 <directivesynopsis>
1093 <name>AuthLDAPDereferenceAliases</name>
1094 <description>When will the module de-reference aliases</description>
1095 <syntax>AuthLDAPDereferenceAliases never|searching|finding|always</syntax>
1096 <default>AuthLDAPDereferenceAliases always</default>
1097 <contextlist><context>directory</context><context>.htaccess</context>
1098 </contextlist>
1099 <override>AuthConfig</override>
1100
1101 <usage>
1102     <p>This directive specifies when <module>mod_authnz_ldap</module> will
1103     de-reference aliases during LDAP operations. The default is
1104     <code>always</code>.</p>
1105 </usage>
1106 </directivesynopsis>
1107
1108 <directivesynopsis>
1109 <name>AuthLDAPGroupAttribute</name>
1110 <description>LDAP attributes used to identify the user members of
1111 groups.</description>
1112 <syntax>AuthLDAPGroupAttribute <em>attribute</em></syntax>
1113 <default>AuthLDAPGroupAttribute member uniquemember</default>
1114 <contextlist><context>directory</context><context>.htaccess</context>
1115 </contextlist>
1116 <override>AuthConfig</override>
1117
1118 <usage>
1119     <p>This directive specifies which LDAP attributes are used to
1120     check for user members within groups. Multiple attributes can be used
1121     by specifying this directive multiple times. If not specified,
1122     then <module>mod_authnz_ldap</module> uses the <code>member</code> and
1123     <code>uniquemember</code> attributes.</p>
1124 </usage>
1125 </directivesynopsis>
1126
1127 <directivesynopsis>
1128 <name>AuthLDAPGroupAttributeIsDN</name>
1129 <description>Use the DN of the client username when checking for
1130 group membership</description>
1131 <syntax>AuthLDAPGroupAttributeIsDN on|off</syntax>
1132 <default>AuthLDAPGroupAttributeIsDN on</default>
1133 <contextlist><context>directory</context><context>.htaccess</context>
1134 </contextlist>
1135 <override>AuthConfig</override>
1136
1137 <usage>
1138     <p>When set <code>on</code>, this directive says to use the
1139     distinguished name of the client username when checking for group
1140     membership.  Otherwise, the username will be used. For example,
1141     assume that the client sent the username <code>bjenson</code>,
1142     which corresponds to the LDAP DN <code>cn=Babs Jenson,
1143     o=Example</code>. If this directive is set,
1144     <module>mod_authnz_ldap</module> will check if the group has
1145     <code>cn=Babs Jenson, o=Example</code> as a member. If this
1146     directive is not set, then <module>mod_authnz_ldap</module> will
1147     check if the group has <code>bjenson</code> as a member.</p>
1148 </usage>
1149 </directivesynopsis>
1150
1151 <directivesynopsis>
1152 <name>AuthLDAPMaxSubGroupDepth</name>
1153 <description>Specifies the maximum sub-group nesting depth that will be
1154 evaluated before the user search is discontinued.</description>
1155 <syntax>AuthLDAPMaxSubGroupDepth <var>Number</var></syntax>
1156 <default>AuthLDAPMaxSubGroupDepth 0</default>
1157 <contextlist><context>directory</context><context>.htaccess</context>
1158 </contextlist>
1159 <override>AuthConfig</override>
1160 <compatibility>Available in version 2.3.0 and later, defaulted to 10 in 2.4.x and early 2.5</compatibility>
1161
1162 <usage>
1163    <p>When this directive is set to a non-zero value <code>X</code>
1164    combined with use of the <code>Require ldap-group someGroupDN</code>
1165    directive, the provided user credentials will be searched for
1166    as a member of the <code>someGroupDN</code> directory object or of
1167    any group member of the current group up to the maximum nesting
1168    level <code>X</code> specified by this directive.</p>
1169    <p>See the <a href="#reqgroup"><code>Require ldap-group</code></a>
1170    section for a more detailed example.</p>
1171
1172    <note><title>Nested groups performance</title>
1173    <p> When <directive>AuthLDAPSubGroupAttribute</directive> overlaps with
1174    <directive>AuthLDAPGroupAttribute</directive> (as it does by default and
1175    as required by common LDAP schemas), uncached searching for subgroups in
1176    large groups can be very slow. If you use large, non-nested groups, keep
1177    <directive>AuthLDAPMaxSubGroupDepth</directive> set to zero.</p>
1178    </note>
1179
1180 </usage>
1181 </directivesynopsis>
1182
1183 <directivesynopsis>
1184 <name>AuthLDAPRemoteUserAttribute</name>
1185 <description>Use the value of the attribute returned during the user
1186 query to set the REMOTE_USER environment variable</description>
1187 <syntax>AuthLDAPRemoteUserAttribute uid</syntax>
1188 <default>none</default>
1189 <contextlist><context>directory</context><context>.htaccess</context>
1190 </contextlist>
1191 <override>AuthConfig</override>
1192
1193 <usage>
1194     <p>If this directive is set, the value of the
1195     <code>REMOTE_USER</code> environment variable will be set to the
1196     value of the attribute specified. Make sure that this attribute is
1197     included in the list of attributes in the AuthLDAPUrl definition,
1198     otherwise this directive will have no effect. This directive, if
1199     present, takes precedence over <directive module="mod_authnz_ldap"
1200     >AuthLDAPRemoteUserIsDN</directive>. This
1201     directive is useful should you want people to log into a website
1202     using an email address, but a backend application expects the
1203     username as a userid.</p>
1204     <p> This directive only has effect when this module is used for
1205     authentication.</p>
1206 </usage>
1207 </directivesynopsis>
1208
1209 <directivesynopsis>
1210 <name>AuthLDAPRemoteUserIsDN</name>
1211 <description>Use the DN of the client username to set the REMOTE_USER
1212 environment variable</description>
1213 <syntax>AuthLDAPRemoteUserIsDN on|off</syntax>
1214 <default>AuthLDAPRemoteUserIsDN off</default>
1215 <contextlist><context>directory</context><context>.htaccess</context>
1216 </contextlist>
1217 <override>AuthConfig</override>
1218
1219 <usage>
1220     <p>If this directive is set to on, the value of the
1221     <code>REMOTE_USER</code> environment variable will be set to the full
1222     distinguished name of the authenticated user, rather than just
1223     the username that was passed by the client. It is turned off by
1224     default.</p>
1225     <p> This directive only has effect when this module is used for
1226     authentication.</p>
1227 </usage>
1228 </directivesynopsis>
1229
1230 <directivesynopsis>
1231 <name>AuthLDAPSearchAsUser</name>
1232 <description>Use the authenticated user's credentials to perform authorization searches</description>
1233 <syntax>AuthLDAPSearchAsUser on|off</syntax>
1234 <default>AuthLDAPSearchAsUser off</default>
1235 <contextlist><context>directory</context><context>.htaccess</context>
1236 </contextlist>
1237 <override>AuthConfig</override>
1238 <compatibility>Available in version 2.3.6 and later</compatibility>
1239
1240 <usage>
1241     <p>When set, and <module>mod_authnz_ldap</module> has authenticated the
1242     user, LDAP searches for authorization use the queried distinguished name (DN)
1243     and HTTP basic authentication password of the authenticated user instead of
1244     the servers configured credentials.</p>
1245
1246     <p> The <em>ldap-filter</em> and <em>ldap-dn</em> authorization
1247     checks use searches.</p>
1248
1249     <p>This directive only has effect on the comparisons performed during
1250     nested group processing when <directive module="mod_authnz_ldap">
1251     AuthLDAPCompareAsUser</directive> is also enabled.</p>
1252
1253     <p> This directive should only be used when your LDAP server doesn't
1254         accept anonymous searches and you cannot use a dedicated
1255         <directive module="mod_authnz_ldap">AuthLDAPBindDN</directive>.
1256     </p>
1257 </usage>
1258 <seealso><directive module="mod_authnz_ldap">AuthLDAPInitialBindAsUser</directive></seealso>
1259 <seealso><directive module="mod_authnz_ldap">AuthLDAPCompareAsUser</directive></seealso>
1260 </directivesynopsis>
1261
1262 <directivesynopsis>
1263 <name>AuthLDAPSubGroupAttribute</name>
1264 <description>Specifies the attribute labels, one value per
1265 directive line, used to distinguish the members of the current group that
1266 are groups.</description>
1267 <syntax>AuthLDAPSubGroupAttribute <em>attribute</em></syntax>
1268 <default>AuthLDAPSubgroupAttribute member uniquemember</default>
1269 <contextlist><context>directory</context><context>.htaccess</context>
1270 </contextlist>
1271 <override>AuthConfig</override>
1272 <compatibility>Available in version 2.3.0 and later</compatibility>
1273
1274 <usage>
1275     <p>An LDAP group object may contain members that are users and
1276     members that are groups (called nested or sub groups). The
1277     <directive>AuthLDAPSubGroupAttribute</directive> directive identifies the
1278     labels of group members and the <directive module="mod_authnz_ldap"
1279     >AuthLDAPGroupAttribute</directive>
1280     directive identifies the labels of the user members. Multiple
1281     attributes can be used by specifying this directive multiple times.
1282     If not specified, then <module>mod_authnz_ldap</module> uses the
1283     <code>member</code> and <code>uniqueMember</code> attributes.</p>
1284 </usage>
1285 </directivesynopsis>
1286
1287 <directivesynopsis>
1288 <name>AuthLDAPSubGroupClass</name>
1289 <description>Specifies which LDAP objectClass values identify directory
1290 objects that are groups during sub-group processing.</description>
1291 <syntax>AuthLDAPSubGroupClass <em>LdapObjectClass</em></syntax>
1292 <default>AuthLDAPSubGroupClass groupOfNames groupOfUniqueNames</default>
1293 <contextlist><context>directory</context><context>.htaccess</context>
1294 </contextlist>
1295 <override>AuthConfig</override>
1296 <compatibility>Available in version 2.3.0 and later</compatibility>
1297
1298 <usage>
1299     <p>An LDAP group object may contain members that are users and
1300     members that are groups (called nested or sub groups). The
1301     <directive module="mod_authnz_ldap">AuthLDAPSubGroupAttribute</directive>
1302     directive identifies the
1303     labels of members that may be sub-groups of the current group
1304     (as opposed to user members). The <directive>AuthLDAPSubGroupClass</directive>
1305     directive specifies the LDAP objectClass values used in verifying that
1306     these potential sub-groups are in fact group objects. Verified sub-groups
1307     can then be searched for more user or sub-group members. Multiple
1308     attributes can be used by specifying this directive multiple times.
1309     If not specified, then <module>mod_authnz_ldap</module> uses the
1310     <code>groupOfNames</code> and <code>groupOfUniqueNames</code> values.</p>
1311 </usage>
1312 </directivesynopsis>
1313
1314 <directivesynopsis>
1315 <name>AuthLDAPUrl</name>
1316 <description>URL specifying the LDAP search parameters</description>
1317 <syntax>AuthLDAPUrl <em>url [NONE|SSL|TLS|STARTTLS]</em></syntax>
1318 <contextlist><context>directory</context><context>.htaccess</context>
1319 </contextlist>
1320 <override>AuthConfig</override>
1321
1322 <usage>
1323     <p>An RFC 2255 URL which specifies the LDAP search parameters
1324     to use. The syntax of the URL is</p>
1325 <example>ldap://host:port/basedn?attribute?scope?filter</example>
1326     <p>If you want to specify more than one LDAP URL that Apache should try in turn, the syntax is:</p>
1327 <highlight language="config">
1328 AuthLDAPUrl "ldap://ldap1.example.com ldap2.example.com/dc=..."
1329 </highlight>
1330 <p><em><strong>Caveat: </strong>If you specify multiple servers, you need to enclose the entire URL string in quotes;
1331 otherwise you will get an error: "AuthLDAPURL takes one argument, URL to define LDAP connection.." </em>
1332 You can of course use search parameters on each of these.</p>
1333
1334 <dl>
1335 <dt>ldap</dt>
1336
1337         <dd>For regular ldap, use the
1338         string <code>ldap</code>. For secure LDAP, use <code>ldaps</code>
1339         instead. Secure LDAP is only available if Apache was linked
1340         to an LDAP library with SSL support.</dd>
1341
1342 <dt>host:port</dt>
1343
1344         <dd>
1345           <p>The name/port of the ldap server (defaults to
1346           <code>localhost:389</code> for <code>ldap</code>, and
1347           <code>localhost:636</code> for <code>ldaps</code>). To
1348           specify multiple, redundant LDAP servers, just list all
1349           servers, separated by spaces. <module>mod_authnz_ldap</module>
1350           will try connecting to each server in turn, until it makes a
1351           successful connection. If multiple ldap servers are specified,
1352           then entire LDAP URL must be encapsulated in double quotes.</p>
1353
1354           <p>Once a connection has been made to a server, that
1355           connection remains active for the life of the
1356           <program>httpd</program> process, or until the LDAP server goes
1357           down.</p>
1358
1359           <p>If the LDAP server goes down and breaks an existing
1360           connection, <module>mod_authnz_ldap</module> will attempt to
1361           re-connect, starting with the primary server, and trying
1362           each redundant server in turn. Note that this is different
1363           than a true round-robin search.</p>
1364         </dd>
1365
1366 <dt>basedn</dt>
1367
1368         <dd>The DN of the branch of the
1369         directory where all searches should start from. At the very
1370         least, this must be the top of your directory tree, but
1371         could also specify a subtree in the directory.</dd>
1372
1373 <dt>attribute</dt>
1374
1375         <dd>The attribute to search for.
1376         Although RFC 2255 allows a comma-separated list of
1377         attributes, only the first attribute will be used, no
1378         matter how many are provided. If no attributes are
1379         provided, the default is to use <code>uid</code>. It's a good
1380         idea to choose an attribute that will be unique across all
1381         entries in the subtree you will be using.  All attributes
1382         listed will be put into the environment with an AUTHENTICATE_ prefix
1383         for use by other modules.</dd>
1384
1385 <dt>scope</dt>
1386
1387         <dd>The scope of the search. Can be either <code>one</code> or
1388         <code>sub</code>. Note that a scope of <code>base</code> is
1389         also supported by RFC 2255, but is not supported by this
1390         module. If the scope is not provided, or if <code>base</code> scope
1391         is specified, the default is to use a scope of
1392         <code>sub</code>.</dd>
1393
1394 <dt>filter</dt>
1395
1396         <dd>A valid LDAP search filter. If
1397         not provided, defaults to <code>(objectClass=*)</code>, which
1398         will search for all objects in the tree. Filters are
1399         limited to approximately 8000 characters (the definition of
1400         <code>MAX_STRING_LEN</code> in the Apache source code). This
1401         should be more than sufficient for any application. In 2.4.10 and later,
1402         the keyword <code>none</code> disables the use of a filter; this is
1403         required by some primitive LDAP servers.</dd>
1404 </dl>
1405
1406     <p>When doing searches, the attribute, filter and username passed
1407     by the HTTP client are combined to create a search filter that
1408     looks like
1409     <code>(&amp;(<em>filter</em>)(<em>attribute</em>=<em>username</em>))</code>.</p>
1410
1411     <p>For example, consider an URL of
1412     <code>ldap://ldap.example.com/o=Example?cn?sub?(posixid=*)</code>. When
1413     a client attempts to connect using a username of <code>Babs
1414     Jenson</code>, the resulting search filter will be
1415     <code>(&amp;(posixid=*)(cn=Babs Jenson))</code>.</p>
1416
1417     <p>An optional parameter can be added to allow the LDAP Url to override
1418     the connection type.  This parameter can be one of the following:</p>
1419
1420 <dl>
1421     <dt>NONE</dt>
1422         <dd>Establish an unsecure connection on the default LDAP port. This
1423         is the same as <code>ldap://</code> on port 389.</dd>
1424     <dt>SSL</dt>
1425         <dd>Establish a secure connection on the default secure LDAP port.
1426         This is the same as <code>ldaps://</code></dd>
1427     <dt>TLS | STARTTLS</dt>
1428         <dd>Establish an upgraded secure connection on the default LDAP port.
1429         This connection will be initiated on port 389 by default and then
1430         upgraded to a secure connection on the same port.</dd>
1431 </dl>
1432
1433     <p>See above for examples of <directive
1434     module="mod_authnz_ldap">AuthLDAPUrl</directive> URLs.</p>
1435 </usage>
1436 </directivesynopsis>
1437
1438 </modulesynopsis>