]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_authnz_ldap.xml
Typo fix as per PR44905, submitted by Jamie Taylor <jamie.taylor@pobox.com>.
[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 <compatibility>Available in version 2.1 and later</compatibility>
32
33 <summary>
34     <p>This module provides authentication front-ends such as
35     <module>mod_auth_basic</module> to authenticate users through 
36     an ldap directory.</p>
37     
38     <p><module>mod_authnz_ldap</module> supports the following features:</p>
39
40     <ul>
41       <li>Known to support the <a
42       href="http://www.openldap.org/">OpenLDAP SDK</a> (both 1.x
43       and 2.x), <a href="http://developer.novell.com/ndk/cldap.htm">
44       Novell LDAP SDK</a> and the <a
45       href="http://www.iplanet.com/downloads/developer/">iPlanet
46       (Netscape)</a> SDK.</li>
47
48       <li>Complex authorization policies can be implemented by
49       representing the policy with LDAP filters.</li>
50
51       <li>Uses extensive caching of LDAP operations via <a
52       href="mod_ldap.html">mod_ldap</a>.</li>
53
54       <li>Support for LDAP over SSL (requires the Netscape SDK) or
55       TLS (requires the OpenLDAP 2.x SDK or Novell LDAP SDK).</li>
56     </ul>
57
58     <p>When using <module>mod_auth_basic</module>, this module is invoked
59     via the <directive module="mod_auth_basic">AuthBasicProvider</directive>
60     directive with the <code>ldap</code> value.</p>
61 </summary>
62
63 <seealso><module>mod_ldap</module></seealso>
64 <seealso><module>mod_auth_basic</module></seealso>
65 <seealso><module>mod_authz_user</module></seealso>
66 <seealso><module>mod_authz_groupfile</module></seealso>
67
68 <section id="contents"><title>Contents</title>
69
70     <ul>
71       <li>
72         <a href="#operation">Operation</a> 
73
74         <ul>
75           <li><a href="#authenphase">The Authentication
76           Phase</a></li>
77
78           <li><a href="#authorphase">The Authorization
79           Phase</a></li>
80         </ul>
81       </li>
82
83       <li>
84         <a href="#requiredirectives">The Require Directives</a> 
85
86         <ul>
87           <li><a href="#reqvaliduser">Require valid-user</a></li>
88           <li><a href="#requser">Require ldap-user</a></li>
89           <li><a href="#reqgroup">Require ldap-group</a></li>
90           <li><a href="#reqdn">Require ldap-dn</a></li>
91           <li><a href="#reqattribute">Require ldap-attribute</a></li>
92           <li><a href="#reqfilter">Require ldap-filter</a></li>
93         </ul>
94       </li>
95
96       <li><a href="#examples">Examples</a></li>
97       <li><a href="#usingtls">Using TLS</a></li>
98       <li><a href="#usingssl">Using SSL</a></li>
99       <li><a href="#exposed">Exposing Login Information</a></li>
100       <li><a href="#activedirectory">Using Active Directory</a></li>
101       <li>
102         <a href="#frontpage">Using Microsoft FrontPage with
103         <module>mod_authnz_ldap</module></a> 
104
105         <ul>
106           <li><a href="#howitworks">How It Works</a></li>
107           <li><a href="#fpcaveats">Caveats</a></li>
108         </ul>
109       </li>
110     </ul>
111 </section>
112
113 <section id="operation"><title>Operation</title>
114
115     <p>There are two phases in granting access to a user. The first
116     phase is authentication, in which the <module>mod_authnz_ldap</module>
117     authentication provider verifies that the user's credentials are valid. 
118     This is also called the <em>search/bind</em> phase. The second phase is
119     authorization, in which <module>mod_authnz_ldap</module> determines
120     if the authenticated user is allowed access to the resource in
121     question. This is also known as the <em>compare</em>
122     phase.</p>
123
124     <p><module>mod_authnz_ldap</module> registers both an authn_ldap authentication
125     provider and an authz_ldap authorization handler.  The authn_ldap
126     authentication provider can be enabled through the 
127     <directive module="mod_auth_basic">AuthBasicProvider</directive> directive 
128     using the <code>ldap</code> value. The authz_ldap handler extends the 
129     <directive module="mod_authz_core">Require</directive> directive's authorization types
130     by adding <code>ldap-user</code>, <code>ldap-dn</code> and <code>ldap-group</code> 
131     values.</p>
132
133 <section id="authenphase"><title>The Authentication
134     Phase</title>
135
136     <p>During the authentication phase, <module>mod_authnz_ldap</module>
137     searches for an entry in the directory that matches the username
138     that the HTTP client passes. If a single unique match is found,
139     then <module>mod_authnz_ldap</module> attempts to bind to the
140     directory server using the DN of the entry plus the password
141     provided by the HTTP client. Because it does a search, then a
142     bind, it is often referred to as the search/bind phase. Here are
143     the steps taken during the search/bind phase.</p>
144
145     <ol>
146       <li>Generate a search filter by combining the attribute and
147       filter provided in the <directive module="mod_authnz_ldap"
148       >AuthLDAPURL</directive> directive with
149       the username passed by the HTTP client.</li>
150
151       <li>Search the directory using the generated filter. If the
152       search does not return exactly one entry, deny or decline
153       access.</li>
154
155       <li>Fetch the distinguished name of the entry retrieved from
156       the search and attempt to bind to the LDAP server using the
157       DN and the password passed by the HTTP client. If the bind is
158       unsuccessful, deny or decline access.</li>
159     </ol>
160
161     <p>The following directives are used during the search/bind
162     phase</p>
163
164     <table>
165       <columnspec><column width=".3"/><column width=".7"/></columnspec>
166       <tr>
167         <td><directive module="mod_authnz_ldap">AuthLDAPURL</directive></td>
168
169         <td>Specifies the LDAP server, the
170         base DN, the attribute to use in the search, as well as the
171         extra search filter to use.</td>
172       </tr>
173
174       <tr>
175         <td><directive module="mod_authnz_ldap">AuthLDAPBindDN</directive></td>
176
177         <td>An optional DN to bind with
178         during the search phase.</td>
179       </tr>
180
181       <tr>
182         <td><directive
183         module="mod_authnz_ldap">AuthLDAPBindPassword</directive></td>
184
185         <td>An optional password to bind
186         with during the search phase.</td>
187       </tr>
188     </table>
189 </section>
190
191 <section id="authorphase"><title>The Authorization Phase</title>
192
193     <p>During the authorization phase, <module>mod_authnz_ldap</module>
194     attempts to determine if the user is authorized to access the
195     resource.  Many of these checks require
196     <module>mod_authnz_ldap</module> to do a compare operation on the
197     LDAP server. This is why this phase is often referred to as the
198     compare phase. <module>mod_authnz_ldap</module> accepts the
199     following <directive module="mod_authz_core">Require</directive>
200     directives to determine if the credentials are acceptable:</p>
201
202     <ul>
203       <li>Grant access if there is a <a
204       href="#reqgroup"><code>Require ldap-user</code></a> directive, and the
205       username in the directive matches the username passed by the
206       client.</li>
207
208       <li>Grant access if there is a <a href="#reqdn"><code>Require
209       ldap-dn</code></a> directive, and the DN in the directive matches
210       the DN fetched from the LDAP directory.</li>
211
212       <li>Grant access if there is a <a
213       href="#reqgroup"><code>Require ldap-group</code></a> directive, and
214       the DN fetched from the LDAP directory (or the username
215       passed by the client) occurs in the LDAP group or, potentially, in
216       one of its sub-groups.</li>
217
218       <li>Grant access if there is a <a href="#reqattribute">
219       <code>Require ldap-attribute</code></a> 
220       directive, and the attribute fetched from the LDAP directory
221       matches the given value.</li> 
222
223       <li>Grant access if there is a <a href="#reqfilter">
224       <code>Require ldap-filter</code></a> 
225       directive, and the search filter successfully finds a single user
226       object that matches the dn of the authenticated user.</li> 
227
228       <li>otherwise, deny or decline access</li>
229     </ul>
230
231     <p>Other <directive module="mod_authz_core">Require</directive> values may also
232     be used which may require loading additional authorization modules.
233     Note that if you use a <directive module="mod_authz_core">Require</directive>
234     value from another authorization module, you will need to ensure that
235     <directive module="mod_authnz_ldap">AuthzLDAPAuthoritative</directive>
236     is set to <code>off</code> to allow the authorization phase to fall
237     back to the module providing the alternate
238     <directive module="mod_authz_core">Require</directive> value.</p>
239
240     <ul>
241         <li>Grant access if there is a <a href="#requser"><code>Require
242         valid-user</code></a> directive. (requires 
243         <module>mod_authz_user</module>)</li>
244
245         <li>Grant access if there is a <a
246         href="#reqgroup"><code>Require group</code></a> directive, and
247         <module>mod_authz_groupfile</module> has been loaded with the 
248         <directive module="mod_authz_groupfile">AuthGroupFile</directive> 
249         directive set.</li>
250     
251         <li>others...</li>
252      </ul>
253
254
255     <p><module>mod_authnz_ldap</module> uses the following directives during the
256     compare phase:</p>
257
258     <table>
259       <columnspec><column width=".4"/><column width=".6"/></columnspec>
260       <tr>
261         <td><directive module="mod_authnz_ldap">AuthLDAPURL</directive> </td>
262
263         <td>The attribute specified in the
264         URL is used in compare operations for the <code>Require
265         ldap-user</code> operation.</td>
266       </tr>
267
268       <tr>
269         <td><directive
270         module="mod_authnz_ldap">AuthLDAPCompareDNOnServer</directive></td>
271
272         <td>Determines the behavior of the
273         <code>Require ldap-dn</code> directive.</td>
274       </tr>
275
276       <tr>
277         <td><directive
278         module="mod_authnz_ldap">AuthLDAPGroupAttribute</directive></td>
279
280         <td>Determines the attribute to
281         use for comparisons in the <code>Require ldap-group</code>
282         directive.</td>
283       </tr>
284
285       <tr>
286         <td><directive
287         module="mod_authnz_ldap">AuthLDAPGroupAttributeIsDN</directive></td>
288
289         <td>Specifies whether to use the
290         user DN or the username when doing comparisons for the
291         <code>Require ldap-group</code> directive.</td>
292       </tr>
293
294       <tr>
295         <td><directive
296         module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive></td>
297
298         <td>Determines the maximum depth of sub-groups that will be evaluated
299         during comparisons in the <code>Require ldap-group</code> directive.</td>
300       </tr>
301
302       <tr>
303         <td><directive
304         module="mod_authnz_ldap">AuthLDAPSubGroupAttribute</directive></td>
305
306         <td>Determines the attribute to use when obtaining sub-group members
307         of the current group during comparisons in the <code>Require ldap-group</code>
308         directive.</td>
309       </tr>
310
311       <tr>
312         <td><directive
313         module="mod_authnz_ldap">AuthLDAPSubGroupClass</directive></td>
314
315         <td>Specifies the LDAP objectClass values used to identify if queried directory
316         objects really are group objects (as opposed to user objects) during the
317         <code>Require ldap-group</code> directive's sub-group processing.</td>
318       </tr>
319     </table>
320 </section>
321 </section>
322
323 <section id="requiredirectives"><title>The Require Directives</title>
324
325     <p>Apache's <directive module="mod_authz_core">Require</directive>
326     directives are used during the authorization phase to ensure that
327     a user is allowed to access a resource.  mod_authnz_ldap extends the 
328     authorization types with <code>ldap-user</code>, <code>ldap-dn</code>, 
329     <code>ldap-group</code>, <code>ldap-attribute</code> and 
330     <code>ldap-filter</code>.  Other authorization types may also be 
331     used but may require that additional authorization modules be loaded.</p>
332
333 <section id="reqvaliduser"><title>Require valid-user</title>
334
335     <p>If this directive exists, <module>mod_authnz_ldap</module> grants
336     access to any user that has successfully authenticated during the
337     search/bind phase.  Requires that <module>mod_authz_user</module> be 
338     loaded.</p>
339 </section>
340
341 <section id="requser"><title>Require ldap-user</title>
342
343     <p>The <code>Require ldap-user</code> directive specifies what
344     usernames can access the resource. Once
345     <module>mod_authnz_ldap</module> has retrieved a unique DN from the
346     directory, it does an LDAP compare operation using the username
347     specified in the <code>Require ldap-user</code> to see if that username
348     is part of the just-fetched LDAP entry.  Multiple users can be
349     granted access by putting multiple usernames on the line,
350     separated with spaces. If a username has a space in it, then it
351     must be surrounded with double quotes. Multiple users can also be
352     granted access by using multiple <code>Require ldap-user</code>
353     directives, with one user per line. For example, with a <directive
354     module="mod_authnz_ldap">AuthLDAPURL</directive> of
355     <code>ldap://ldap/o=Airius?cn</code> (i.e., <code>cn</code> is
356     used for searches), the following Require directives could be used
357     to restrict access:</p>
358 <example>
359 Require ldap-user "Barbara Jenson"<br />
360 Require ldap-user "Fred User"<br />
361 Require ldap-user "Joe Manager"<br />
362 </example>
363
364     <p>Because of the way that <module>mod_authnz_ldap</module> handles this
365     directive, Barbara Jenson could sign on as <em>Barbara
366     Jenson</em>, <em>Babs Jenson</em> or any other <code>cn</code> that
367     she has in her LDAP entry. Only the single <code>Require
368     ldap-user</code> line is needed to support all values of the attribute
369     in the user's entry.</p>
370
371     <p>If the <code>uid</code> attribute was used instead of the
372     <code>cn</code> attribute in the URL above, the above three lines
373     could be condensed to</p>
374 <example>Require ldap-user bjenson fuser jmanager</example>
375 </section>
376
377 <section id="reqgroup"><title>Require ldap-group</title>
378
379     <p>This directive specifies an LDAP group whose members are
380     allowed access. It takes the distinguished name of the LDAP
381     group. Note: Do not surround the group name with quotes.
382     For example, assume that the following entry existed in
383     the LDAP directory:</p>
384 <example>
385 dn: cn=Administrators, o=Airius<br />
386 objectClass: groupOfUniqueNames<br />
387 uniqueMember: cn=Barbara Jenson, o=Airius<br />
388 uniqueMember: cn=Fred User, o=Airius<br />
389 </example>
390
391     <p>The following directive would grant access to both Fred and
392     Barbara:</p>
393 <example>Require ldap-group cn=Administrators, o=Airius</example>
394
395     <p>Members can also be found within sub-groups of a specified LDAP group
396     if <directive module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive>
397     is set to a value greater than 0. For example, assume the following entries
398     exist in the LDAP directory:</p>
399 <example>
400 dn: cn=Employees, o=Airius<br />
401 objectClass: groupOfUniqueNames<br />
402 uniqueMember: cn=Managers, o=Airius<br />
403 uniqueMember: cn=Administrators, o=Airius<br />
404 uniqueMember: cn=Users, o=Airius<br />
405 <br />
406 dn: cn=Managers, o=Airius<br />
407 objectClass: groupOfUniqueNames<br />
408 uniqueMember: cn=Bob Ellis, o=Airius<br />
409 uniqueMember: cn=Tom Jackson, o=Airius<br />
410 <br />
411 dn: cn=Administrators, o=Airius<br />
412 objectClass: groupOfUniqueNames<br />
413 uniqueMember: cn=Barbara Jenson, o=Airius<br />
414 uniqueMember: cn=Fred User, o=Airius<br />
415 <br />
416 dn: cn=Users, o=Airius<br />
417 objectClass: groupOfUniqueNames<br />
418 uniqueMember: cn=Allan Jefferson, o=Airius<br />
419 uniqueMember: cn=Paul Tilley, o=Airius<br />
420 uniqueMember: cn=Temporary Employees, o=Airius<br />
421 <br />
422 dn: cn=Temporary Employees, o=Airius<br />
423 objectClass: groupOfUniqueNames<br />
424 uniqueMember: cn=Jim Swenson, o=Airius<br />
425 uniqueMember: cn=Elliot Rhodes, o=Airius<br />
426 </example>
427
428     <p>The following directives would allow access for Bob Ellis, Tom Jackson,
429     Barbara Jensen, Fred User, Allan Jefferson, and Paul Tilley but would not
430     allow access for Jim Swenson, or Elliot Rhodes (since they are at a 
431     sub-group depth of 2):</p>
432 <example>
433 Require ldap-group cn=Employees, o-Airius<br />
434 AuthLDAPSubGroupDepth 1<br />
435 </example>
436
437     <p>Behavior of this directive is modified by the <directive
438     module="mod_authnz_ldap">AuthLDAPGroupAttribute</directive>, <directive
439     module="mod_authnz_ldap">AuthLDAPGroupAttributeIsDN</directive>, <directive
440     module="mod_authnz_ldap">AuthLDAPMaxSubGroupDepth</directive>, <directive
441     module="mod_authnz_ldap">AuthLDAPSubGroupAttribute</directive>, and <directive
442     module="mod_authnz_ldap">AuthLDAPSubGroupClass</directive>
443     directives.</p>
444 </section>
445
446 <section id="reqdn"><title>Require ldap-dn</title>
447
448     <p>The <code>Require ldap-dn</code> directive allows the administrator
449     to grant access based on distinguished names. It specifies a DN
450     that must match for access to be granted. If the distinguished
451     name that was retrieved from the directory server matches the
452     distinguished name in the <code>Require ldap-dn</code>, then
453     authorization is granted. Note: do not surround the distinguished
454     name with quotes.</p>
455
456     <p>The following directive would grant access to a specific
457     DN:</p>
458 <example>Require ldap-dn cn=Barbara Jenson, o=Airius</example>
459
460     <p>Behavior of this directive is modified by the <directive
461     module="mod_authnz_ldap">AuthLDAPCompareDNOnServer</directive>
462     directive.</p>
463 </section>
464
465 <section id="reqattribute"><title>Require ldap-attribute</title>
466
467     <p>The <code>Require ldap-attribute</code> directive allows the
468     administrator to grant access based on attributes of the authenticated
469     user in the LDAP directory.  If the attribute in the directory
470     matches the value given in the configuration, access is granted.</p>
471     
472     <p>The following directive would grant access to anyone with
473     the attribute employeeType = active</p>
474
475     <example>Require ldap-attribute employeeType=active</example>
476
477     <p>Multiple attribute/value pairs can be specified on the same line
478     separated by spaces or they can be specified in multiple 
479     <code>Require ldap-attribute</code> directives. The effect of listing 
480     multiple attribute/values pairs is an OR operation. Access will be 
481     granted if any of the listed attribute values match the value of the 
482     corresponding attribute in the user object. If the value of the 
483     attribute contains a space, only the value must be within double quotes.</p>
484
485     <p>The following directive would grant access to anyone with
486     the city attribute equal to "San Jose" or status equal to "Active"</p>
487
488     <example>Require ldap-attribute city="San Jose" status=active</example>
489
490 </section>
491
492 <section id="reqfilter"><title>Require ldap-filter</title>
493
494     <p>The <code>Require ldap-filter</code> directive allows the
495     administrator to grant access based on a complex LDAP search filter.
496     If the dn returned by the filter search matches the authenticated user
497     dn, access is granted.</p>
498     
499     <p>The following directive would grant access to anyone having a cell phone
500     and is in the marketing department</p>
501
502     <example>Require ldap-filter &amp;(cell=*)(department=marketing)</example>
503
504     <p>The difference between the <code>Require ldap-filter</code> directive and the 
505     <code>Require ldap-attribute</code> directive is that <code>ldap-filter</code> 
506     performs a search operation on the LDAP directory using the specified search 
507     filter rather than a simple attribute comparison. If a simple attribute 
508     comparison is all that is required, the comparison operation performed by 
509     <code>ldap-attribute</code> will be faster than the search operation 
510     used by <code>ldap-filter</code> especially within a large directory.</p>
511
512 </section>
513
514 </section>
515
516 <section id="examples"><title>Examples</title>
517
518     <ul>
519       <li>
520         Grant access to anyone who exists in the LDAP directory,
521         using their UID for searches. 
522 <example>
523 AuthLDAPURL "ldap://ldap1.airius.com:389/ou=People, o=Airius?uid?sub?(objectClass=*)"<br />
524 Require valid-user
525 </example>
526       </li>
527
528       <li>
529         The next example is the same as above; but with the fields
530         that have useful defaults omitted. Also, note the use of a
531         redundant LDAP server. 
532 <example>AuthLDAPURL "ldap://ldap1.airius.com ldap2.airius.com/ou=People, o=Airius"<br />
533 Require valid-user
534 </example>
535       </li>
536
537       <li>
538         The next example is similar to the previous one, but it
539         uses the common name instead of the UID. Note that this
540         could be problematical if multiple people in the directory
541         share the same <code>cn</code>, because a search on <code>cn</code>
542         <strong>must</strong> return exactly one entry. That's why
543         this approach is not recommended: it's a better idea to
544         choose an attribute that is guaranteed unique in your
545         directory, such as <code>uid</code>. 
546 <example>
547 AuthLDAPURL "ldap://ldap.airius.com/ou=People, o=Airius?cn"<br />
548 Require valid-user
549 </example>
550       </li>
551
552       <li>
553         Grant access to anybody in the Administrators group. The
554         users must authenticate using their UID. 
555 <example>
556 AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid<br />
557 Require ldap-group cn=Administrators, o=Airius
558 </example>
559       </li>
560
561       <li>
562         The next example assumes that everyone at Airius who
563         carries an alphanumeric pager will have an LDAP attribute
564         of <code>qpagePagerID</code>. The example will grant access
565         only to people (authenticated via their UID) who have
566         alphanumeric pagers: 
567 <example>
568 AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid??(qpagePagerID=*)<br />
569 Require valid-user
570 </example>
571       </li>
572
573       <li>
574         <p>The next example demonstrates the power of using filters
575         to accomplish complicated administrative requirements.
576         Without filters, it would have been necessary to create a
577         new LDAP group and ensure that the group's members remain
578         synchronized with the pager users. This becomes trivial
579         with filters. The goal is to grant access to anyone who has
580         a pager, plus grant access to Joe Manager, who doesn't
581         have a pager, but does need to access the same
582         resource:</p>
583 <example>
584 AuthLDAPURL ldap://ldap.airius.com/o=Airius?uid??(|(qpagePagerID=*)(uid=jmanager))<br />
585 Require valid-user
586 </example>
587
588         <p>This last may look confusing at first, so it helps to
589         evaluate what the search filter will look like based on who
590         connects, as shown below.  If
591         Fred User connects as <code>fuser</code>, the filter would look
592         like</p>
593
594         <example>(&amp;(|(qpagePagerID=*)(uid=jmanager))(uid=fuser))</example>
595
596         <p>The above search will only succeed if <em>fuser</em> has a
597         pager. When Joe Manager connects as <em>jmanager</em>, the
598         filter looks like</p>
599
600         <example>(&amp;(|(qpagePagerID=*)(uid=jmanager))(uid=jmanager))</example>
601
602         <p>The above search will succeed whether <em>jmanager</em>
603         has a pager or not.</p>
604       </li>
605     </ul>
606 </section>
607
608 <section id="usingtls"><title>Using TLS</title>
609
610     <p>To use TLS, see the <module>mod_ldap</module> directives <directive
611     module="mod_ldap">LDAPTrustedClientCert</directive>, <directive
612     module="mod_ldap">LDAPTrustedGlobalCert</directive> and <directive
613     module="mod_ldap">LDAPTrustedMode</directive>.</p>
614
615     <p>An optional second parameter can be added to the 
616     <directive module="mod_authnz_ldap">AuthLDAPURL</directive> to override
617     the default connection type set by <directive module="mod_ldap">LDAPTrustedMode</directive>.
618     This will allow the connection established by an <em>ldap://</em> Url 
619     to be upgraded to a secure connection on the same port.</p>
620 </section>
621
622 <section id="usingssl"><title>Using SSL</title>
623
624     <p>To use SSL, see the <module>mod_ldap</module> directives <directive
625     module="mod_ldap">LDAPTrustedClientCert</directive>, <directive
626     module="mod_ldap">LDAPTrustedGlobalCert</directive> and <directive
627     module="mod_ldap">LDAPTrustedMode</directive>.</p>
628
629     <p>To specify a secure LDAP server, use <em>ldaps://</em> in the
630     <directive module="mod_authnz_ldap">AuthLDAPURL</directive>
631     directive, instead of <em>ldap://</em>.</p>
632 </section>
633
634 <section id="exposed"><title>Exposing Login Information</title>
635
636     <p>When this module performs authentication, LDAP attributes specified
637     in the <directive module="mod_authnz_ldap">AuthLDAPUrl</directive> 
638     directive are placed in environment variables with the prefix "AUTHENTICATE_".</p>
639
640     <p>If the attribute field contains the username, common name
641     and telephone number of a user, a CGI program will have access to
642     this information without the need to make a second independent LDAP
643     query to gather this additional information.</p>
644
645     <p>This has the potential to dramatically simplify the coding and
646     configuration required in some web applications.</p>
647
648 </section>
649
650 <section id="activedirectory"><title>Using Active Directory</title>
651
652     <p>An Active Directory installation may support multiple domains at the
653     same time. To distinguish users between domains, an identifier called
654     a User Principle Name (UPN) can be added to a user's entry in the
655     directory. This UPN usually takes the form of the user's account
656     name, followed by the domain components of the particular domain,
657     for example <em>somebody@nz.somedomain.com</em>.</p>
658
659     <p>You may wish to configure the <module>mod_authnz_ldap</module>
660     module to authenticate users present in any of the domains making up
661     the Active Directory forest. In this way both
662     <em>somebody@nz.somedomain.com</em> and <em>someone@au.somedomain.com</em>
663     can be authenticated using the same query at the same time.</p>
664
665     <p>To make this practical, Active Directory supports the concept of
666     a Global Catalog. This Global Catalog is a read only copy of selected
667     attributes of all the Active Directory servers within the Active
668     Directory forest. Querying the Global Catalog allows all the domains
669     to be queried in a single query, without the query spanning servers
670     over potentially slow links.</p>
671
672     <p>If enabled, the Global Catalog is an independent directory server
673     that runs on port 3268 (3269 for SSL). To search for a user, do a
674     subtree search for the attribute <em>userPrincipalName</em>, with
675     an empty search root, like so:</p>
676
677 <example>
678 AuthLDAPBindDN apache@somedomain.com<br />
679 AuthLDAPBindPassword password<br />
680 AuthLDAPURL ldap://10.0.0.1:3268/?userPrincipalName?sub
681 </example>
682
683     <p>Users will need to enter their User Principal Name as a login, in
684     the form <em>somebody@nz.somedomain.com</em>.</p>
685
686 </section>
687
688 <section id="frontpage"><title>Using Microsoft
689     FrontPage with mod_authnz_ldap</title>
690
691     <p>Normally, FrontPage uses FrontPage-web-specific user/group
692     files (i.e., the <module>mod_authn_file</module> and
693     <module>mod_authz_groupfile</module> modules) to handle all
694     authentication. Unfortunately, it is not possible to just
695     change to LDAP authentication by adding the proper directives,
696     because it will break the <em>Permissions</em> forms in
697     the FrontPage client, which attempt to modify the standard
698     text-based authorization files.</p>
699
700     <p>Once a FrontPage web has been created, adding LDAP
701     authentication to it is a matter of adding the following
702     directives to <em>every</em> <code>.htaccess</code> file
703     that gets created in the web</p>
704 <example><pre>
705 AuthLDAPURL            "the url"
706 AuthGroupFile <em>mygroupfile</em>
707 Require group <em>mygroupfile</em>
708 </pre></example>
709
710 <section id="howitworks"><title>How It Works</title>
711
712     <p>FrontPage restricts access to a web by adding the <code>Require
713     valid-user</code> directive to the <code>.htaccess</code>
714     files. The <code>Require valid-user</code> directive will succeed for
715     any user who is valid <em>as far as LDAP is
716     concerned</em>. This means that anybody who has an entry in
717     the LDAP directory is considered a valid user, whereas FrontPage
718     considers only those people in the local user file to be
719     valid. By substituting the ldap-group with group file authorization,
720     Apache is allowed to consult the local user file (which is managed by 
721     FrontPage) - instead of LDAP - when handling authorizing the user.</p>
722
723     <p>Once directives have been added as specified above,
724     FrontPage users will be able to perform all management
725     operations from the FrontPage client.</p>
726 </section>
727
728 <section id="fpcaveats"><title>Caveats</title>
729
730     <ul>
731       <li>When choosing the LDAP URL, the attribute to use for
732       authentication should be something that will also be valid
733       for putting into a <module>mod_authn_file</module> user file.
734       The user ID is ideal for this.</li>
735
736       <li>When adding users via FrontPage, FrontPage administrators
737       should choose usernames that already exist in the LDAP
738       directory (for obvious reasons). Also, the password that the
739       administrator enters into the form is ignored, since Apache
740       will actually be authenticating against the password in the
741       LDAP database, and not against the password in the local user
742       file. This could cause confusion for web administrators.</li>
743
744       <!-- XXX is that true? was mod_auth before the aaa change -->
745       <li>Apache must be compiled with <module>mod_auth_basic</module>,
746       <module>mod_authn_file</module> and
747       <module>mod_authz_groupfile</module> in order to
748       use FrontPage support. This is because Apache will still use
749       the <module>mod_authz_groupfile</module> group file for determine 
750       the extent of a user's access to the FrontPage web.</li>
751
752       <li>The directives must be put in the <code>.htaccess</code>
753       files. Attempting to put them inside <directive module="core"
754       type="section">Location</directive> or <directive module="core"
755       type="section">Directory</directive> directives won't work. This
756       is because <module>mod_authnz_ldap</module> has to be able to grab
757       the <directive module="mod_authn_file">AuthGroupFile</directive>
758       directive that is found in FrontPage <code>.htaccess</code>
759       files so that it knows where to look for the valid user list. If
760       the <module>mod_authnz_ldap</module> directives aren't in the same
761       <code>.htaccess</code> file as the FrontPage directives, then
762       the hack won't work, because <module>mod_authnz_ldap</module> will
763       never get a chance to process the <code>.htaccess</code> file,
764       and won't be able to find the FrontPage-managed user file.</li>
765     </ul>
766 </section>
767 </section>
768
769 <directivesynopsis>
770 <name>AuthLDAPBindDN</name>
771 <description>Optional DN to use in binding to the LDAP server</description>
772 <syntax>AuthLDAPBindDN <em>distinguished-name</em></syntax>
773 <contextlist><context>directory</context><context>.htaccess</context>
774 </contextlist>
775 <override>AuthConfig</override>
776
777 <usage>
778     <p>An optional DN used to bind to the server when searching for
779     entries. If not provided, <module>mod_authnz_ldap</module> will use
780     an anonymous bind.</p>
781 </usage>
782 </directivesynopsis>
783
784 <directivesynopsis>
785 <name>AuthLDAPBindPassword</name>
786 <description>Password used in conjuction with the bind DN</description>
787 <syntax>AuthLDAPBindPassword <em>password</em></syntax>
788 <contextlist><context>directory</context><context>.htaccess</context>
789 </contextlist>
790 <override>AuthConfig</override>
791
792 <usage>
793     <p>A bind password to use in conjunction with the bind DN. Note
794     that the bind password is probably sensitive data, and should be
795     properly protected. You should only use the <directive
796     module="mod_authnz_ldap">AuthLDAPBindDN</directive> and <directive
797     module="mod_authnz_ldap">AuthLDAPBindPassword</directive> if you
798     absolutely need them to search the directory.</p> 
799 </usage>
800 </directivesynopsis>
801
802 <directivesynopsis>
803 <name>AuthLDAPCharsetConfig</name>
804 <description>Language to charset conversion configuration file</description>
805 <syntax>AuthLDAPCharsetConfig <em>file-path</em></syntax>
806 <contextlist><context>server config</context>
807 </contextlist>
808
809 <usage>
810     <p>The <directive>AuthLDAPCharsetConfig</directive> directive sets the location
811     of the language to charset conversion configuration file. <var>File-path</var> is relative
812     to the <directive module="core">ServerRoot</directive>. This file specifies
813     the list of language extensions to character sets.
814     Most administrators use the provided <code>charset.conv</code>
815     file, which associates common language extensions to character sets.</p>
816
817     <p>The file contains lines in the following format:</p>
818
819     <example>
820       <var>Language-Extension</var> <var>charset</var> [<var>Language-String</var>] ...
821     </example>
822
823     <p>The case of the extension does not matter. Blank lines, and lines
824     beginning with a hash character (<code>#</code>) are ignored.</p>
825 </usage>
826 </directivesynopsis>
827
828 <directivesynopsis>
829 <name>AuthLDAPCompareDNOnServer</name>
830 <description>Use the LDAP server to compare the DNs</description>
831 <syntax>AuthLDAPCompareDNOnServer on|off</syntax>
832 <default>AuthLDAPCompareDNOnServer on</default>
833 <contextlist><context>directory</context><context>.htaccess</context>
834 </contextlist>
835 <override>AuthConfig</override>
836
837 <usage>
838     <p>When set, <module>mod_authnz_ldap</module> will use the LDAP
839     server to compare the DNs. This is the only foolproof way to
840     compare DNs.  <module>mod_authnz_ldap</module> will search the
841     directory for the DN specified with the <a
842     href="#reqdn"><code>Require dn</code></a> directive, then,
843     retrieve the DN and compare it with the DN retrieved from the user
844     entry. If this directive is not set,
845     <module>mod_authnz_ldap</module> simply does a string comparison. It
846     is possible to get false negatives with this approach, but it is
847     much faster. Note the <module>mod_ldap</module> cache can speed up
848     DN comparison in most situations.</p>
849 </usage>
850 </directivesynopsis>
851
852 <directivesynopsis>
853 <name>AuthLDAPDereferenceAliases</name>
854 <description>When will the module de-reference aliases</description>
855 <syntax>AuthLDAPDereferenceAliases never|searching|finding|always</syntax>
856 <default>AuthLDAPDereferenceAliases always</default>
857 <contextlist><context>directory</context><context>.htaccess</context>
858 </contextlist>
859 <override>AuthConfig</override>
860
861 <usage>
862     <p>This directive specifies when <module>mod_authnz_ldap</module> will
863     de-reference aliases during LDAP operations. The default is
864     <code>always</code>.</p>
865 </usage>
866 </directivesynopsis>
867
868 <directivesynopsis>
869 <name>AuthLDAPGroupAttribute</name>
870 <description>LDAP attributes used to identify the user members of
871 groups.</description>
872 <syntax>AuthLDAPGroupAttribute <em>attribute</em></syntax>
873 <contextlist><context>directory</context><context>.htaccess</context>
874 </contextlist>
875 <override>AuthConfig</override>
876
877 <usage>
878     <p>This directive specifies which LDAP attributes are used to
879     check for user members within groups. Multiple attributes can be used
880     by specifying this directive multiple times. If not specified,
881     then <module>mod_authnz_ldap</module> uses the <code>member</code> and
882     <code>uniquemember</code> attributes.</p>
883 </usage>
884 </directivesynopsis>
885
886 <directivesynopsis>
887 <name>AuthLDAPGroupAttributeIsDN</name>
888 <description>Use the DN of the client username when checking for
889 group membership</description>
890 <syntax>AuthLDAPGroupAttributeIsDN on|off</syntax>
891 <default>AuthLDAPGroupAttributeIsDN on</default>
892 <contextlist><context>directory</context><context>.htaccess</context>
893 </contextlist>
894 <override>AuthConfig</override>
895
896 <usage>
897     <p>When set <code>on</code>, this directive says to use the
898     distinguished name of the client username when checking for group
899     membership.  Otherwise, the username will be used. For example,
900     assume that the client sent the username <code>bjenson</code>,
901     which corresponds to the LDAP DN <code>cn=Babs Jenson,
902     o=Airius</code>. If this directive is set,
903     <module>mod_authnz_ldap</module> will check if the group has
904     <code>cn=Babs Jenson, o=Airius</code> as a member. If this
905     directive is not set, then <module>mod_authnz_ldap</module> will
906     check if the group has <code>bjenson</code> as a member.</p>
907 </usage>
908 </directivesynopsis>
909
910 <directivesynopsis>
911 <name>AuthLDAPMaxSubGroupDepth</name>
912 <description>Specifies the maximum sub-group nesting depth that will be
913 evaluated before the user search is discontinued.</description>
914 <syntax>AuthLDAPMaxSubGroupDepth <var>Number</var></syntax>
915 <default>AuthLDAPMaxSubGroupDepth 10</default>
916 <contextlist><context>directory</context><context>.htaccess</context>
917 </contextlist>
918 <override>AuthConfig</override>
919
920 <usage>
921    <p>When this directive is set to a non-zero value <code>X</code>
922    combined with use of the <code>Require ldap-group someGroupDN</code>
923    directive, the provided user credentials will be searched for
924    as a member of the <code>someGroupDN</code> directory object or of
925    any group member of the current group up to the maximum nesting
926    level <code>X</code> specified by this directive.</p>
927    <p>See the <a href="#reqgroup"><code>Require ldap-group</code></a>
928    section for a more detailed example.</p>
929 </usage>
930 </directivesynopsis>
931
932 <directivesynopsis>
933 <name>AuthLDAPRemoteUserAttribute</name>
934 <description>Use the value of the attribute returned during the user
935 query to set the REMOTE_USER environment variable</description>
936 <syntax>AuthLDAPRemoteUserAttribute uid</syntax>
937 <default>none</default>
938 <contextlist><context>directory</context><context>.htaccess</context>
939 </contextlist>
940 <override>AuthConfig</override> 
941       
942 <usage>
943     <p>If this directive is set, the value of the 
944     <code>REMOTE_USER</code> environment variable will be set to the
945     value of the attribute specified. Make sure that this attribute is
946     included in the list of attributes in the AuthLDAPUrl definition,
947     otherwise this directive will have no effect. This directive, if
948     present, takes precedence over AuthLDAPRemoteUserIsDN. This
949     directive is useful should you want people to log into a website
950     using an email address, but a backend application expects the
951     username as a userid.</p>
952 </usage>
953 </directivesynopsis>
954
955 <directivesynopsis>
956 <name>AuthLDAPRemoteUserIsDN</name>
957 <description>Use the DN of the client username to set the REMOTE_USER
958 environment variable</description>
959 <syntax>AuthLDAPRemoteUserIsDN on|off</syntax>
960 <default>AuthLDAPRemoteUserIsDN off</default>
961 <contextlist><context>directory</context><context>.htaccess</context>
962 </contextlist>
963 <override>AuthConfig</override>
964
965 <usage>
966     <p>If this directive is set to on, the value of the
967     <code>REMOTE_USER</code> environment variable will be set to the full
968     distinguished name of the authenticated user, rather than just
969     the username that was passed by the client. It is turned off by
970     default.</p>
971 </usage>
972 </directivesynopsis>
973
974 <directivesynopsis>
975 <name>AuthLDAPSubGroupAttribute</name>
976 <description>Specifies the attribute labels, one value per
977 directive line, used to distinguish the members of the current group that
978 are groups.</description>
979 <syntax>AuthLDAPSubGroupAttribute <em>attribute</em></syntax>
980 <contextlist><context>directory</context><context>.htaccess</context>
981 </contextlist>
982 <override>AuthConfig</override>
983
984 <usage>
985     <p>An LDAP group object may contain members that are users and
986     members that are groups (called nested or sub groups). The
987     <code>AuthLDAPSubGroupAttribute</code> directive identifies the
988     labels of group members and the <code>AuthLDAPGroupAttribute</code>
989     directive identifies the labels of the user members. Multiple
990     attributes can be used by specifying this directive multiple times.
991     If not specified, then <module>mod_authnz_ldap</module> uses the
992     <code>member</code> and <code>uniqueMember</code> attributes.</p>
993 </usage>
994 </directivesynopsis>
995
996 <directivesynopsis>
997 <name>AuthLDAPSubGroupClass</name>
998 <description>Specifies which LDAP objectClass values identify directory
999 objects that are groups during sub-group processing.</description>
1000 <syntax>AuthLDAPSubGroupClass <em>LdapObjectClass</em></syntax>
1001 <contextlist><context>directory</context><context>.htaccess</context>
1002 </contextlist>
1003 <override>AuthConfig</override>
1004
1005 <usage>
1006     <p>An LDAP group object may contain members that are users and
1007     members that are groups (called nested or sub groups). The
1008     <code>AuthLDAPSubGroupAttribute</code> directive identifies the
1009     labels of members that may be sub-groups of the current group
1010     (as opposed to user members). The <code>AuthLDAPSubGroupClass</code>
1011     directive specifies the LDAP objectClass values used in verifying that
1012     these potential sub-groups are in fact group objects. Verified sub-groups
1013     can then be searched for more user or sub-group members. Multiple
1014     attributes can be used by specifying this directive multiple times.
1015     If not specified, then <module>mod_authnz_ldap</module> uses the
1016     <code>groupOfNames</code> and <code>groupOfUniqueNames</code> values.</p>
1017 </usage>
1018 </directivesynopsis>
1019
1020 <directivesynopsis>
1021 <name>AuthLDAPUrl</name>
1022 <description>URL specifying the LDAP search parameters</description>
1023 <syntax>AuthLDAPUrl <em>url [NONE|SSL|TLS|STARTTLS]</em></syntax>
1024 <contextlist><context>directory</context><context>.htaccess</context>
1025 </contextlist>
1026 <override>AuthConfig</override>
1027
1028 <usage>
1029     <p>An RFC 2255 URL which specifies the LDAP search parameters
1030     to use. The syntax of the URL is</p>
1031 <example>ldap://host:port/basedn?attribute?scope?filter</example>
1032     <p>If you want to specify more than one LDAP URL that Apache should try in turn, the syntax is:</p>
1033 <example>AuthLDAPUrl "ldap://ldap1.example.com ldap2.example.com"</example>
1034 <p><em><strong>Caveat: </strong>If you specify multiple servers, you need to enclose the entire URL string in quotes; 
1035 otherwise you will get an error: "AuthLDAPURL takes one argument, URL to define LDAP connection.." </em> 
1036 You can of course use search parameters on each of these.</p>
1037
1038 <dl>
1039 <dt>ldap</dt>
1040
1041         <dd>For regular ldap, use the
1042         string <code>ldap</code>. For secure LDAP, use <code>ldaps</code>
1043         instead. Secure LDAP is only available if Apache was linked
1044         to an LDAP library with SSL support.</dd>
1045
1046 <dt>host:port</dt>
1047
1048         <dd>
1049           <p>The name/port of the ldap server (defaults to
1050           <code>localhost:389</code> for <code>ldap</code>, and
1051           <code>localhost:636</code> for <code>ldaps</code>). To
1052           specify multiple, redundant LDAP servers, just list all
1053           servers, separated by spaces. <module>mod_authnz_ldap</module>
1054           will try connecting to each server in turn, until it makes a
1055           successful connection. If multiple ldap servers are specified, 
1056           then entire LDAP URL must be encapsulated in double quotes.</p>
1057
1058           <p>Once a connection has been made to a server, that
1059           connection remains active for the life of the
1060           <program>httpd</program> process, or until the LDAP server goes
1061           down.</p>
1062
1063           <p>If the LDAP server goes down and breaks an existing
1064           connection, <module>mod_authnz_ldap</module> will attempt to
1065           re-connect, starting with the primary server, and trying
1066           each redundant server in turn. Note that this is different
1067           than a true round-robin search.</p>
1068         </dd>
1069
1070 <dt>basedn</dt>
1071
1072         <dd>The DN of the branch of the
1073         directory where all searches should start from. At the very
1074         least, this must be the top of your directory tree, but
1075         could also specify a subtree in the directory.</dd>
1076
1077 <dt>attribute</dt>
1078
1079         <dd>The attribute to search for.
1080         Although RFC 2255 allows a comma-separated list of
1081         attributes, only the first attribute will be used, no
1082         matter how many are provided. If no attributes are
1083         provided, the default is to use <code>uid</code>. It's a good
1084         idea to choose an attribute that will be unique across all
1085         entries in the subtree you will be using.  All attributes
1086         listed will be put into the environment with an AUTHENTICATE_ prefix
1087         for use by other modules.</dd>
1088
1089 <dt>scope</dt>
1090
1091         <dd>The scope of the search. Can be either <code>one</code> or
1092         <code>sub</code>. Note that a scope of <code>base</code> is
1093         also supported by RFC 2255, but is not supported by this
1094         module. If the scope is not provided, or if <code>base</code> scope
1095         is specified, the default is to use a scope of
1096         <code>sub</code>.</dd>
1097
1098 <dt>filter</dt>
1099
1100         <dd>A valid LDAP search filter. If
1101         not provided, defaults to <code>(objectClass=*)</code>, which
1102         will search for all objects in the tree. Filters are
1103         limited to approximately 8000 characters (the definition of
1104         <code>MAX_STRING_LEN</code> in the Apache source code). This
1105         should be more than sufficient for any application.</dd>
1106 </dl>
1107
1108     <p>When doing searches, the attribute, filter and username passed
1109     by the HTTP client are combined to create a search filter that
1110     looks like
1111     <code>(&amp;(<em>filter</em>)(<em>attribute</em>=<em>username</em>))</code>.</p>
1112
1113     <p>For example, consider an URL of
1114     <code>ldap://ldap.airius.com/o=Airius?cn?sub?(posixid=*)</code>. When
1115     a client attempts to connect using a username of <code>Babs
1116     Jenson</code>, the resulting search filter will be
1117     <code>(&amp;(posixid=*)(cn=Babs Jenson))</code>.</p>
1118
1119     <p>An optional parameter can be added to allow the LDAP Url to override 
1120     the connection type.  This parameter can be one of the following:</p>
1121
1122 <dl>
1123     <dt>NONE</dt>
1124         <dd>Establish an unsecure connection on the default LDAP port. This
1125         is the same as <code>ldap://</code> on port 389.</dd>
1126     <dt>SSL</dt>
1127         <dd>Establish a secure connection on the default secure LDAP port.
1128         This is the same as <code>ldaps://</code></dd>
1129     <dt>TLS | STARTTLS</dt>
1130         <dd>Establish an upgraded secure connection on the default LDAP port.
1131         This connection will be initiated on port 389 by default and then 
1132         upgraded to a secure connection on the same port.</dd>
1133 </dl>
1134
1135     <p>See above for examples of <directive
1136     module="mod_authnz_ldap">AuthLDAPURL</directive> URLs.</p>
1137 </usage>
1138 </directivesynopsis>
1139
1140 </modulesynopsis>