バージョンごとのドキュメント一覧

34.18. 接続パラメータのLDAP検索 #

<title>LDAP Lookup of Connection Parameters</title>

If <application>libpq</application> has been compiled with LDAP support (option <literal><option>&#45;-with-ldap</option></literal> for <command>configure</command>) it is possible to retrieve connection options like <literal>host</literal> or <literal>dbname</literal> via LDAP from a central server. The advantage is that if the connection parameters for a database change, the connection information doesn't have to be updated on all client machines. libpqがLDAPサポート(configure時の--with-ldapオプション)付きでコンパイルされている場合、中央サーバからLDAPを通してhostdbnameなどの接続オプションを取り出すことができます。 この利点は、データベースの接続パラメータが変わった場合に、すべてのクライアントマシンで接続情報を更新しなくても済む点です。

LDAP connection parameter lookup uses the connection service file <filename>pg_service.conf</filename> (see <xref linkend="libpq-pgservice"/>). A line in a <filename>pg_service.conf</filename> stanza that starts with <literal>ldap://</literal> will be recognized as an LDAP URL and an LDAP query will be performed. The result must be a list of <literal>keyword = value</literal> pairs which will be used to set connection options. The URL must conform to <ulink url="https://tools.ietf.org/html/rfc1959">RFC 1959</ulink> and be of the form LDAP接続パラメータ検索は、pg_service.confという接続サービスファイル(34.17を参照)を使用します。 pg_service.conf内のldap://から始まる行は、LDAP URLとして認識され、LDAP問い合わせが実行されることを示します。 その結果は、keyword = valueという組み合わせのリストでなければなりません。 これらが接続用オプションの設定に使用されます。 このURLは RFC 1959に従ったもので、以下のような形式でなければなりません。

ldap://[hostname[:port]]/search_base?attribute?search_scope?filter

where <replaceable>hostname</replaceable> defaults to <literal>localhost</literal> and <replaceable>port</replaceable> defaults to 389. ここで、hostnameのデフォルトはlocalhostportのデフォルトは389です。

Processing of <filename>pg_service.conf</filename> is terminated after a successful LDAP lookup, but is continued if the LDAP server cannot be contacted. This is to provide a fallback with further LDAP URL lines that point to different LDAP servers, classical <literal>keyword = value</literal> pairs, or default connection options. If you would rather get an error message in this case, add a syntactically incorrect line after the LDAP URL. pg_service.confの処理はLDAP検索が成功した時に終わります。 しかし、もしLDAPサーバへのアクセスができなかった場合は継続します。 これはアクセスに失敗した時に、異なるLDAPサーバを指し示す他のLDAP行や以前からのkeyword = valueの組み合わせ、デフォルトの接続オプションを参照する予備機能を提供します。 この場合にエラーメッセージを受け取りたい場合は、LDAP URL行の後に文法的に不正な行を記載してください。

A sample LDAP entry that has been created with the LDIF file LDIFファイルとして作成されたLDAP項目の例を以下に示します。

version:1
dn:cn=mydatabase,dc=mycompany,dc=com
changetype:add
objectclass:top
objectclass:device
cn:mydatabase
description:host=dbserver.mycompany.com
description:port=5439
description:dbname=mydb
description:user=mydb_user
description:sslmode=require

might be queried with the following LDAP URL: これは、以下のようなLDAP URLから得られます。

ldap://ldap.mycompany.com/dc=mycompany,dc=com?description?one?(cn=mydatabase)

You can also mix regular service file entries with LDAP lookups. A complete example for a stanza in <filename>pg_service.conf</filename> would be: また、LDAP検索と通常のサービスファイル項目とを混在させることもできます。 pg_service.confの一節について完全な例を以下に示します。

# only host and port are stored in LDAP, specify dbname and user explicitly
[customerdb]
dbname=customer
user=appuser
ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*)