@@ -1362,6 +1362,7 @@ omicron bryanh guest1
13621362
13631363 <para>
13641364 LDAP authentication can operate in two modes. In the first mode,
1365+ which we will call the simple bind mode,
13651366 the server will bind to the distinguished name constructed as
13661367 <replaceable>prefix</> <replaceable>username</> <replaceable>suffix</>.
13671368 Typically, the <replaceable>prefix</> parameter is used to specify
@@ -1371,24 +1372,27 @@ omicron bryanh guest1
13711372 </para>
13721373
13731374 <para>
1374- In the second mode, the server first binds to the LDAP directory with
1375+ In the second mode, which we will call the search+bind mode,
1376+ the server first binds to the LDAP directory with
13751377 a fixed user name and password, specified with <replaceable>ldapbinduser</>
13761378 and <replaceable>ldapbinddn</>, and performs a search for the user trying
13771379 to log in to the database. If no user and password is configured, an
13781380 anonymous bind will be attempted to the directory. The search will be
13791381 performed over the subtree at <replaceable>ldapbasedn</>, and will try to
13801382 do an exact match of the attribute specified in
1381- <replaceable>ldapsearchattribute</>. If no attribute is specified, the
1382- <literal>uid</> attribute will be used. Once the user has been found in
1383+ <replaceable>ldapsearchattribute</>.
1384+ Once the user has been found in
13831385 this search, the server disconnects and re-binds to the directory as
13841386 this user, using the password specified by the client, to verify that the
1385- login is correct. This method allows for significantly more flexibility
1387+ login is correct. This mode is the same as that used by LDAP authentication
1388+ schemes in other software, such as Apache mod_authnz_ldap and pam_ldap.
1389+ This method allows for significantly more flexibility
13861390 in where the user objects are located in the directory, but will cause
13871391 two separate connections to the LDAP server to be made.
13881392 </para>
13891393
13901394 <para>
1391- The following configuration options are supported for LDAP :
1395+ The following configuration options are used in both modes :
13921396 <variablelist>
13931397 <varlistentry>
13941398 <term><literal>ldapserver</literal></term>
@@ -1419,6 +1423,10 @@ omicron bryanh guest1
14191423 </para>
14201424 </listitem>
14211425 </varlistentry>
1426+ </variablelist>
1427+
1428+ The following options are used in simple bind mode only:
1429+ <variablelist>
14221430 <varlistentry>
14231431 <term><literal>ldapprefix</literal></term>
14241432 <listitem>
@@ -1437,6 +1445,10 @@ omicron bryanh guest1
14371445 </para>
14381446 </listitem>
14391447 </varlistentry>
1448+ </variablelist>
1449+
1450+ The following options are used in search+bind mode only:
1451+ <variablelist>
14401452 <varlistentry>
14411453 <term><literal>ldapbasedn</literal></term>
14421454 <listitem>
@@ -1469,23 +1481,52 @@ omicron bryanh guest1
14691481 <listitem>
14701482 <para>
14711483 Attribute to match against the user name in the search when doing
1472- search+bind authentication.
1484+ search+bind authentication. If no attribute is specified, the
1485+ <literal>uid</> attribute will be used.
14731486 </para>
14741487 </listitem>
14751488 </varlistentry>
14761489 </variablelist>
14771490 </para>
14781491
1479- <note>
1492+ <para>
1493+ It is an error to mix configuration options for simple bind with options
1494+ for search+bind.
1495+ </para>
1496+
1497+ <para>
1498+ Here is an example for a simple-bind LDAP configuration:
1499+ <programlisting>
1500+ host ... ldap ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
1501+ </programlisting>
1502+ When a connection to the database server as database
1503+ user <literal>someuser</literal> is requested, PostgreSQL will attempt to
1504+ bind to the LDAP server using the DN <literal>cn=someuser, dc=example,
1505+ dc=net</literal> and the password provided by the client. If that connection
1506+ succeeds, the database access is granted.
1507+ </para>
1508+
1509+ <para>
1510+ Here is an exaple for a search+bind configuration:
1511+ <programlisting>
1512+ host ... ldap ldapserver=ldap.example.net ldapbasedn="dc=example, dc=net" ldapsearchattribute=uid
1513+ </programlisting>
1514+ When a connection to the database server as database
1515+ user <literal>someuser</literal> is requested, PostgreSQL will attempt to
1516+ bind anonymously (since <literal>ldapbinddn</literal> was not specified) to
1517+ the LDAP server, perform a search for <literal>(uid=someuser)</literal>
1518+ under the specified base DN. If an entry is found, it will then attempt to
1519+ bind using that found information and the password supplied by the client.
1520+ If that second connection succeeds, the database access is granted.
1521+ </para>
1522+
1523+ <tip>
14801524 <para>
14811525 Since LDAP often uses commas and spaces to separate the different
14821526 parts of a DN, it is often necessary to use double-quoted parameter
1483- values when configuring LDAP options, for example:
1484- <programlisting>
1485- ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
1486- </programlisting>
1527+ values when configuring LDAP options, as shown in the examples.
14871528 </para>
1488- </note >
1529+ </tip >
14891530
14901531 </sect2>
14911532
0 commit comments