gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

62 lines
5.4KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>33.17. LDAP Lookup of Connection Parameters</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="libpq-pgservice.html" title="33.16. The Connection Service File" /><link rel="next" href="libpq-ssl.html" title="33.18. SSL Support" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">33.17. LDAP Lookup of Connection Parameters</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="libpq-pgservice.html" title="33.16. The Connection Service File">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="libpq.html" title="Chapter 33. libpq - C Library">Up</a></td><th width="60%" align="center">Chapter 33. <span xmlns="http://www.w3.org/1999/xhtml" class="application">libpq</span> - C Library</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="libpq-ssl.html" title="33.18. SSL Support">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="LIBPQ-LDAP"><div class="titlepage"><div><div><h2 class="title" style="clear: both">33.17. LDAP Lookup of Connection Parameters</h2></div></div></div><a id="id-1.7.3.24.2" class="indexterm"></a><p>
  3. If <span class="application">libpq</span> has been compiled with LDAP support (option
  4. <code class="literal"><code class="option">--with-ldap</code></code> for <code class="command">configure</code>)
  5. it is possible to retrieve connection options like <code class="literal">host</code>
  6. or <code class="literal">dbname</code> via LDAP from a central server.
  7. The advantage is that if the connection parameters for a database change,
  8. the connection information doesn't have to be updated on all client machines.
  9. </p><p>
  10. LDAP connection parameter lookup uses the connection service file
  11. <code class="filename">pg_service.conf</code> (see <a class="xref" href="libpq-pgservice.html" title="33.16. The Connection Service File">Section 33.16</a>). A line in a
  12. <code class="filename">pg_service.conf</code> stanza that starts with
  13. <code class="literal">ldap://</code> will be recognized as an LDAP URL and an
  14. LDAP query will be performed. The result must be a list of
  15. <code class="literal">keyword = value</code> pairs which will be used to set
  16. connection options. The URL must conform to RFC 1959 and be of the
  17. form
  18. </p><pre class="synopsis">
  19. ldap://[<em class="replaceable"><code>hostname</code></em>[:<em class="replaceable"><code>port</code></em>]]/<em class="replaceable"><code>search_base</code></em>?<em class="replaceable"><code>attribute</code></em>?<em class="replaceable"><code>search_scope</code></em>?<em class="replaceable"><code>filter</code></em>
  20. </pre><p>
  21. where <em class="replaceable"><code>hostname</code></em> defaults to
  22. <code class="literal">localhost</code> and <em class="replaceable"><code>port</code></em>
  23. defaults to 389.
  24. </p><p>
  25. Processing of <code class="filename">pg_service.conf</code> is terminated after
  26. a successful LDAP lookup, but is continued if the LDAP server cannot
  27. be contacted. This is to provide a fallback with further LDAP URL
  28. lines that point to different LDAP servers, classical <code class="literal">keyword
  29. = value</code> pairs, or default connection options. If you would
  30. rather get an error message in this case, add a syntactically incorrect
  31. line after the LDAP URL.
  32. </p><p>
  33. A sample LDAP entry that has been created with the LDIF file
  34. </p><pre class="programlisting">
  35. version:1
  36. dn:cn=mydatabase,dc=mycompany,dc=com
  37. changetype:add
  38. objectclass:top
  39. objectclass:device
  40. cn:mydatabase
  41. description:host=dbserver.mycompany.com
  42. description:port=5439
  43. description:dbname=mydb
  44. description:user=mydb_user
  45. description:sslmode=require
  46. </pre><p>
  47. might be queried with the following LDAP URL:
  48. </p><pre class="programlisting">
  49. ldap://ldap.mycompany.com/dc=mycompany,dc=com?description?one?(cn=mydatabase)
  50. </pre><p>
  51. </p><p>
  52. You can also mix regular service file entries with LDAP lookups.
  53. A complete example for a stanza in <code class="filename">pg_service.conf</code>
  54. would be:
  55. </p><pre class="programlisting">
  56. # only host and port are stored in LDAP, specify dbname and user explicitly
  57. [customerdb]
  58. dbname=customer
  59. user=appuser
  60. ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*)
  61. </pre><p>
  62. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="libpq-pgservice.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="libpq.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="libpq-ssl.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">33.16. The Connection Service File </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 33.18. SSL Support</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1