Zend_Auth_Adapter_Ldap.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.auth.adapter.ldap">
  4. <title>LDAP Authentication</title>
  5. <sect2 id="zend.auth.adapter.ldap.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Auth_Adapter_Ldap</classname> supports web application authentication with LDAP services. Its
  9. features include username and domain name canonicalization, multi-domain authentication, and failover
  10. capabilities. It has been tested to work with
  11. <ulink url="http://www.microsoft.com/windowsserver2003/technologies/directory/activedirectory/">Microsoft
  12. Active Directory</ulink> and <ulink url="http://www.openldap.org/">OpenLDAP</ulink>, but it should also
  13. work with other LDAP service providers.
  14. </para>
  15. <para>
  16. This documentation includes a guide on using <classname>Zend_Auth_Adapter_Ldap</classname>, an exploration of its
  17. API, an outline of the various available options, diagnostic information for troubleshooting authentication
  18. problems, and example options for both Active Directory and OpenLDAP servers.
  19. </para>
  20. </sect2>
  21. <sect2 id="zend.auth.adapter.ldap.usage">
  22. <title>Usage</title>
  23. <para>
  24. To incorporate <classname>Zend_Auth_Adapter_Ldap</classname> authentication into your application quickly, even if
  25. you're not using <classname>Zend_Controller</classname>, the meat of your code should look something like the
  26. following:
  27. <programlisting role="php"><![CDATA[
  28. $username = $this->_request->getParam('username');
  29. $password = $this->_request->getParam('password');
  30. $auth = Zend_Auth::getInstance();
  31. $config = new Zend_Config_Ini('../application/config/config.ini',
  32. 'production');
  33. $log_path = $config->ldap->log_path;
  34. $options = $config->ldap->toArray();
  35. unset($options['log_path']);
  36. $adapter = new Zend_Auth_Adapter_Ldap($options, $username,
  37. $password);
  38. $result = $auth->authenticate($adapter);
  39. if ($log_path) {
  40. $messages = $result->getMessages();
  41. $logger = new Zend_Log();
  42. $logger->addWriter(new Zend_Log_Writer_Stream($log_path));
  43. $filter = new Zend_Log_Filter_Priority(Zend_Log::DEBUG);
  44. $logger->addFilter($filter);
  45. foreach ($messages as $i => $message) {
  46. if ($i-- > 1) { // $messages[2] and up are log messages
  47. $message = str_replace("\n", "\n ", $message);
  48. $logger->log("Ldap: $i: $message", Zend_Log::DEBUG);
  49. }
  50. }
  51. }
  52. ]]></programlisting>
  53. Of course, the logging code is optional, but it is highly recommended that you use a logger.
  54. <classname>Zend_Auth_Adapter_Ldap</classname> will record just about every bit of information anyone could want in
  55. <code>$messages</code> (more below), which is a nice feature in itself for something that has a history of
  56. being notoriously difficult to debug.
  57. </para>
  58. <para>
  59. The <classname>Zend_Config_Ini</classname> code is used above to load the adapter options. It is also optional. A
  60. regular array would work equally well. The following is an example
  61. <code>application/config/config.ini</code> file that has options for two separate servers. With multiple
  62. sets of server options the adapter will try each, in order, until the credentials are successfully
  63. authenticated. The names of the servers (e.g., <code>server1</code> and <code>server2</code>) are largely
  64. arbitrary. For details regarding the options array, see the <emphasis>Server Options</emphasis> section
  65. below. Note that <classname>Zend_Config_Ini</classname> requires that any values with "equals" characters
  66. (<code>=</code>) will need to be quoted (like the DNs shown below).
  67. <programlisting role="ini"><![CDATA[
  68. [production]
  69. ldap.log_path = /tmp/ldap.log
  70. ; Typical options for OpenLDAP
  71. ldap.server1.host = s0.foo.net
  72. ldap.server1.accountDomainName = foo.net
  73. ldap.server1.accountDomainNameShort = FOO
  74. ldap.server1.accountCanonicalForm = 3
  75. ldap.server1.username = "CN=user1,DC=foo,DC=net"
  76. ldap.server1.password = pass1
  77. ldap.server1.baseDn = "OU=Sales,DC=foo,DC=net"
  78. ldap.server1.bindRequiresDn = true
  79. ; Typical options for Active Directory
  80. ldap.server2.host = dc1.w.net
  81. ldap.server2.useStartTls = true
  82. ldap.server2.accountDomainName = w.net
  83. ldap.server2.accountDomainNameShort = W
  84. ldap.server2.accountCanonicalForm = 3
  85. ldap.server2.baseDn = "CN=Users,DC=w,DC=net"
  86. ]]></programlisting>
  87. The above configuration will instruct <classname>Zend_Auth_Adapter_Ldap</classname> to attempt to authenticate users
  88. with the OpenLDAP server <code>s0.foo.net</code> first. If the authentication fails for any reason, the AD
  89. server <code>dc1.w.net</code> will be tried.
  90. </para>
  91. <para>
  92. With servers in different domains, this configuration illustrates multi-domain authentication. You can also
  93. have multiple servers in the same domain to provide redundancy.
  94. </para>
  95. <para>
  96. Note that in this case, even though OpenLDAP has no need for the short NetBIOS style domain name used by
  97. Windows, we provide it here for name canonicalization purposes (described in the
  98. <emphasis>Username Canonicalization</emphasis> section below).
  99. </para>
  100. </sect2>
  101. <sect2 id="zend.auth.adapter.ldap.api">
  102. <title>The API</title>
  103. <para>
  104. The <classname>Zend_Auth_Adapter_Ldap</classname> constructor accepts three parameters.
  105. </para>
  106. <para>
  107. The <code>$options</code> parameter is required and must be an array containing one or more sets of
  108. options. Note that it is <emphasis>an array of arrays</emphasis> of
  109. <link linkend="zend.ldap"><classname>Zend_Ldap</classname></link> options. Even if you will be using only one LDAP server, the
  110. options must still be within another array.
  111. </para>
  112. <para>
  113. Below is <ulink url="http://php.net/print_r"><code>print_r()</code></ulink> output of an example options
  114. parameter containing two sets of server options for LDAP servers <code>s0.foo.net</code> and
  115. <code>dc1.w.net</code> (the same options as the above INI representation):
  116. <programlisting role="output"><![CDATA[
  117. Array
  118. (
  119. [server2] => Array
  120. (
  121. [host] => dc1.w.net
  122. [useStartTls] => 1
  123. [accountDomainName] => w.net
  124. [accountDomainNameShort] => W
  125. [accountCanonicalForm] => 3
  126. [baseDn] => CN=Users,DC=w,DC=net
  127. )
  128. [server1] => Array
  129. (
  130. [host] => s0.foo.net
  131. [accountDomainName] => foo.net
  132. [accountDomainNameShort] => FOO
  133. [accountCanonicalForm] => 3
  134. [username] => CN=user1,DC=foo,DC=net
  135. [password] => pass1
  136. [baseDn] => OU=Sales,DC=foo,DC=net
  137. [bindRequiresDn] => 1
  138. )
  139. )
  140. ]]></programlisting>
  141. The information provided in each set of options above is different mainly because AD does not require a
  142. username be in DN form when binding (see the <code>bindRequiresDn</code> option in the
  143. <emphasis>Server Options</emphasis> section below), which means we can omit a number of options
  144. associated with retrieving the DN for a username being authenticated.
  145. </para>
  146. <note>
  147. <title>What is a Distinguished Name?</title>
  148. <para>
  149. A DN or "distinguished name" is a string that represents the path to an object within the LDAP
  150. directory. Each comma-separated component is an attribute and value representing a node. The components
  151. are evaluated in reverse. For example, the user account
  152. <emphasis>CN=Bob Carter,CN=Users,DC=w,DC=net</emphasis> is located directly within the
  153. <emphasis>CN=Users,DC=w,DC=net container</emphasis>. This structure is best explored with an LDAP
  154. browser like the ADSI Edit MMC snap-in for Active Directory or phpLDAPadmin.
  155. </para>
  156. </note>
  157. <para>
  158. The names of servers (e.g. '<code>server1</code>' and '<code>server2</code>' shown above) are largely
  159. arbitrary, but for the sake of using <classname>Zend_Config</classname>, the identifiers should be present (as
  160. opposed to being numeric indexes) and should not contain any special characters used by the associated file
  161. formats (e.g. the '<code>.</code>' INI property separator, '<code>&amp;</code>' for XML entity references,
  162. etc).
  163. </para>
  164. <para>
  165. With multiple sets of server options, the adapter can authenticate users in multiple domains and provide
  166. failover so that if one server is not available, another will be queried.
  167. </para>
  168. <note>
  169. <title>The Gory Details: What Happens in the Authenticate Method?</title>
  170. <para>
  171. When the <code>authenticate()</code> method is called, the adapter iterates over each set of server
  172. options, sets them on the internal <classname>Zend_Ldap</classname> instance, and calls the
  173. <classname>Zend_Ldap::bind()</classname> method with the username and password being authenticated. The
  174. <classname>Zend_Ldap</classname> class checks to see if the username is qualified with a domain (e.g., has a
  175. domain component like <emphasis>alice@foo.net</emphasis> or <emphasis>FOO\alice</emphasis>). If a
  176. domain is present, but does not match either of the server's domain names
  177. (<emphasis>foo.net</emphasis> or <emphasis>FOO</emphasis>), a special exception is thrown and caught by
  178. <classname>Zend_Auth_Adapter_Ldap</classname> that causes that server to be ignored and the next set of server
  179. options is selected. If a domain <emphasis>does</emphasis> match, or if the user did not supply a
  180. qualified username, <classname>Zend_Ldap</classname> proceeds to try to bind with the supplied credentials. If
  181. the bind is not successful, <classname>Zend_Ldap</classname> throws a <classname>Zend_Ldap_Exception</classname> which is
  182. caught by <classname>Zend_Auth_Adapter_Ldap</classname> and the next set of server options is tried. If the bind
  183. is successful, the iteration stops, and the adapter's <code>authenticate()</code> method returns a
  184. successful result. If all server options have been tried without success, the authentication fails, and
  185. <code>authenticate()</code> returns a failure result with error messages from the last iteration.
  186. </para>
  187. </note>
  188. <para>
  189. The username and password parameters of the <classname>Zend_Auth_Adapter_Ldap</classname> constructor represent the
  190. credentials being authenticated (i.e., the credentials supplied by the user through your HTML login form).
  191. Alternatively, they may also be set with the <code>setUsername()</code> and <code>setPassword()</code>
  192. methods.
  193. </para>
  194. </sect2>
  195. <sect2 id="zend.auth.adapter.ldap.server-options">
  196. <title>Server Options</title>
  197. <para>
  198. Each set of server options <emphasis>in the context of <classname>Zend_Auth_Adapter_Ldap</classname></emphasis> consists of the
  199. following options, which are passed, largely unmodified, to <classname>Zend_Ldap::setOptions()</classname>:
  200. <table id="zend.auth.adapter.ldap.server-options.table">
  201. <title>Server Options</title>
  202. <tgroup cols="2">
  203. <thead>
  204. <row>
  205. <entry>Name</entry>
  206. <entry>Description</entry>
  207. </row>
  208. </thead>
  209. <tbody>
  210. <row>
  211. <entry><emphasis role="strong">host</emphasis></entry>
  212. <entry>
  213. The hostname of LDAP server that these options represent. This option is required.
  214. </entry>
  215. </row>
  216. <row>
  217. <entry><emphasis role="strong">port</emphasis></entry>
  218. <entry>
  219. The port on which the LDAP server is listening. If <emphasis role="strong">useSsl</emphasis> is
  220. <code>true</code>, the default <emphasis role="strong">port</emphasis> value is 636. If
  221. <emphasis role="strong">useSsl</emphasis> is <code>false</code>, the default
  222. <emphasis role="strong">port</emphasis> value is 389.
  223. </entry>
  224. </row>
  225. <row>
  226. <entry>useStartTls</entry>
  227. <entry>
  228. Whether or not the LDAP client should use TLS (aka SSLv2) encrypted transport. A value of
  229. <code>true</code> is strongly favored in production environments to prevent passwords from
  230. be transmitted in clear text. The default value is <code>false</code>, as servers
  231. frequently require that a certificate be installed separately after installation.
  232. The <code>useSsl</code> and <code>useStartTls</code> options are mutually exclusive.
  233. The <code>useStartTls</code> option should be favored over <code>useSsl</code> but
  234. not all servers support this newer mechanism.
  235. </entry>
  236. </row>
  237. <row>
  238. <entry>useSsl</entry>
  239. <entry>
  240. Whether or not the LDAP client should use SSL encrypted transport. The <code>useSsl</code>
  241. and <code>useStartTls</code> options are mutually exclusive, but <code>useStartTls</code>
  242. should be favored if the server and LDAP client library support it.
  243. This value also changes the default <emphasis role="strong">port</emphasis> value (see
  244. <emphasis role="strong">port</emphasis> description above).
  245. </entry>
  246. </row>
  247. <row>
  248. <entry><emphasis role="strong">username</emphasis></entry>
  249. <entry>
  250. The DN of the account used to perform account DN lookups. LDAP servers that require the
  251. username to be in DN form when performing the "bind" require this option. Meaning, if
  252. <emphasis role="strong">bindRequiresDn</emphasis> is <code>true</code>, this option is
  253. required. This account does not need to be a privileged account; an account with read-only
  254. access to objects under the <emphasis role="strong">baseDn</emphasis> is all that is necessary
  255. (and preferred based on the <emphasis>Principle of Least Privilege</emphasis>).
  256. </entry>
  257. </row>
  258. <row>
  259. <entry><emphasis role="strong">password</emphasis></entry>
  260. <entry>
  261. The password of the account used to perform account DN lookups. If this option is not supplied,
  262. the LDAP client will attempt an "anonymous bind" when performing account DN lookups.
  263. </entry>
  264. </row>
  265. <row>
  266. <entry><emphasis role="strong">bindRequiresDn</emphasis></entry>
  267. <entry>
  268. Some LDAP servers require that the username used to bind be in DN form like
  269. <emphasis>CN=Alice Baker,OU=Sales,DC=foo,DC=net</emphasis> (basically all servers
  270. <emphasis>except</emphasis> AD). If this option is <code>true</code>, this instructs
  271. <classname>Zend_Ldap</classname> to automatically retrieve the DN corresponding to the username being
  272. authenticated, if it is not already in DN form, and then re-bind with the proper DN. The
  273. default value is <code>false</code>. Currently only Microsoft Active Directory Server (ADS) is
  274. known <emphasis>not</emphasis> to require usernames to be in DN form when binding, and
  275. therefore this option may be <code>false</code> with AD (and it should be, as retrieving the DN
  276. requires an extra round trip to the server). Otherwise, this option must be set to
  277. <code>true</code> (e.g. for OpenLDAP). This option also controls the default
  278. <emphasis role="strong">acountFilterFormat</emphasis> used when searching for accounts. See the
  279. <emphasis role="strong">accountFilterFormat</emphasis> option.
  280. </entry>
  281. </row>
  282. <row>
  283. <entry><emphasis role="strong">baseDn</emphasis></entry>
  284. <entry>
  285. The DN under which all accounts being authenticated are located. This option is required. If
  286. you are uncertain about the correct <emphasis role="strong">baseDn</emphasis> value, it should
  287. be sufficient to derive it from the user's DNS domain using <emphasis>DC=</emphasis>
  288. components. For example, if the user's principal name is <emphasis>alice@foo.net</emphasis>, a
  289. <emphasis role="strong">baseDn</emphasis> of <emphasis>DC=foo,DC=net</emphasis> should work. A
  290. more precise location (e.g., <emphasis>OU=Sales,DC=foo,DC=net</emphasis>) will be more
  291. efficient, however.
  292. </entry>
  293. </row>
  294. <row>
  295. <entry><emphasis role="strong">accountCanonicalForm</emphasis></entry>
  296. <entry>
  297. A value of 2, 3 or 4 indicating the form to which account names should be canonicalized after
  298. successful authentication. Values are as follows: 2 for traditional username style names (e.g.,
  299. <emphasis>alice</emphasis>), 3 for backslash-style names (e.g., <emphasis>FOO\alice</emphasis>)
  300. or 4 for principal style usernames (e.g., <emphasis>alice@foo.net</emphasis>). The default
  301. value is 4 (e.g., <emphasis>alice@foo.net</emphasis>). For example, with a value of 3, the
  302. identity returned by <classname>Zend_Auth_Result::getIdentity()</classname> (and
  303. <classname>Zend_Auth::getIdentity()</classname>, if <classname>Zend_Auth</classname> was used) will always be
  304. <emphasis>FOO\alice</emphasis>, regardless of what form Alice supplied, whether it be
  305. <emphasis>alice</emphasis>, <emphasis>alice@foo.net</emphasis>, <emphasis>FOO\alice</emphasis>,
  306. <emphasis>FoO\aLicE</emphasis>, <emphasis>foo.net\alice</emphasis>, etc. See the
  307. <emphasis>Account Name Canonicalization</emphasis> section in the <classname>Zend_Ldap</classname>
  308. documentation for details. Note that when using multiple sets of server options it is
  309. recommended, but not required, that the same
  310. <emphasis role="strong">accountCanonicalForm</emphasis> be used with all server options so that
  311. the resulting usernames are always canonicalized to the same form (e.g., if you canonicalize to
  312. <emphasis>EXAMPLE\username</emphasis> with an AD server but to
  313. <emphasis>username@example.com</emphasis> with an OpenLDAP server, that may be awkward for the
  314. application's high-level logic).
  315. </entry>
  316. </row>
  317. <row>
  318. <entry><emphasis role="strong">accountDomainName</emphasis></entry>
  319. <entry>
  320. The FQDN domain name for which the target LDAP server is an authority (e.g.,
  321. <code>example.com</code>). This option is used to canonicalize names so that the username
  322. supplied by the user can be converted as necessary for binding. It is also used to determine if
  323. the server is an authority for the supplied username (e.g., if
  324. <emphasis role="strong">accountDomainName</emphasis> is <emphasis>foo.net</emphasis> and the
  325. user supplies <emphasis>bob@bar.net</emphasis>, the server will not be queried, and a failure
  326. will result). This option is not required, but if it is not supplied, usernames in principal
  327. name form (e.g., <emphasis>alice@foo.net</emphasis>) are not supported. It is strongly
  328. recommended that you supply this option, as there are many use-cases that require generating
  329. the principal name form.
  330. </entry>
  331. </row>
  332. <row>
  333. <entry><emphasis role="strong">accountDomainNameShort</emphasis></entry>
  334. <entry>
  335. The 'short' domain for which the target LDAP server is an authority (e.g.,
  336. <emphasis>FOO</emphasis>). Note that there is a 1:1 mapping between the
  337. <emphasis role="strong">accountDomainName</emphasis> and
  338. <emphasis role="strong">accountDomainNameShort</emphasis>. This option should be used to
  339. specify the NetBIOS domain name for Windows networks, but may also be used by non-AD servers
  340. (e.g., for consistency when multiple sets of server options with the backslash style
  341. <emphasis role="strong">accountCanonicalForm</emphasis>). This option is not required but if it
  342. is not supplied, usernames in backslash form (e.g., <emphasis>FOO\alice</emphasis>) are not
  343. supported.
  344. </entry>
  345. </row>
  346. <row>
  347. <entry><emphasis role="strong">accountFilterFormat</emphasis></entry>
  348. <entry>
  349. The LDAP search filter used to search for accounts. This string is a
  350. <ulink url="http://php.net/printf"><code>printf()</code></ulink>-style expression that must
  351. contain one '<code>%s</code>' to accomodate the username. The default value is
  352. '<code>(&amp;(objectClass=user)(sAMAccountName=%s))</code>', unless
  353. <emphasis role="strong">bindRequiresDn</emphasis> is set to <code>true</code>, in which case
  354. the default is '<code>(&amp;(objectClass=posixAccount)(uid=%s))</code>'. For example, if for
  355. some reason you wanted to use <code>bindRequiresDn = true</code> with AD you would need to set
  356. <code>accountFilterFormat = '(&amp;(objectClass=user)(sAMAccountName=%s))</code>'.
  357. </entry>
  358. </row>
  359. <row>
  360. <entry><emphasis role="strong">optReferrals</emphasis></entry>
  361. <entry>
  362. If set to <code>true</code>, this option indicates to the LDAP client that referrals should
  363. be followed. The default value is <code>false</code>.
  364. </entry>
  365. </row>
  366. </tbody>
  367. </tgroup>
  368. </table>
  369. </para>
  370. <note>
  371. <para>
  372. If you enable <code>useStartTls = true</code> or <code>useSsl = true</code> you may find that
  373. the LDAP client generates an error
  374. claiming that it cannot validate the server's certificate. Assuming the PHP LDAP extension is
  375. ultimately linked to the OpenLDAP client libraries, to resolve this issue you can set
  376. "<code>TLS_REQCERT never</code>" in the OpenLDAP client <code>ldap.conf</code> (and restart the web
  377. server) to indicate to the OpenLDAP client library that you trust the server. Alternatively, if you are
  378. concerned that the server could be spoofed, you can export the LDAP server's root certificate and put
  379. it on the web server so that the OpenLDAP client can validate the server's identity.
  380. </para>
  381. </note>
  382. </sect2>
  383. <sect2 id="zend.auth.adapter.ldap.debugging">
  384. <title>Collecting Debugging Messages</title>
  385. <para>
  386. <classname>Zend_Auth_Adapter_Ldap</classname> collects debugging information within its <code>authenticate()</code>
  387. method. This information is stored in the <classname>Zend_Auth_Result</classname> object as messages. The array
  388. returned by <classname>Zend_Auth_Result::getMessages()</classname> is described as follows:
  389. <table id="zend.auth.adapter.ldap.debugging.table">
  390. <title>Debugging Messages</title>
  391. <tgroup cols="2">
  392. <thead>
  393. <row>
  394. <entry>Messages Array Index</entry>
  395. <entry>Description</entry>
  396. </row>
  397. </thead>
  398. <tbody>
  399. <row>
  400. <entry>Index 0</entry>
  401. <entry>
  402. A generic, user-friendly message that is suitable for displaying to users (e.g., "Invalid
  403. credentials"). If the authentication is successful, this string is empty.
  404. </entry>
  405. </row>
  406. <row>
  407. <entry>Index 1</entry>
  408. <entry>
  409. A more detailed error message that is not suitable to be displayed to users but should be
  410. logged for the benefit of server operators. If the authentication is successful, this string is
  411. empty.
  412. </entry>
  413. </row>
  414. <row>
  415. <entry>Indexes 2 and higher</entry>
  416. <entry>
  417. All log messages in order starting at index 2.
  418. </entry>
  419. </row>
  420. </tbody>
  421. </tgroup>
  422. </table>
  423. In practice, index 0 should be displayed to the user (e.g., using the FlashMessenger helper), index 1 should
  424. be logged and, if debugging information is being collected, indexes 2 and higher could be logged as well
  425. (although the final message always includes the string from index 1).
  426. </para>
  427. </sect2>
  428. <sect2 id="zend.auth.adapter.ldap.options-common-server-specific">
  429. <title>Common Options for Specific Servers</title>
  430. <sect3 id="zend.auth.adapter.ldap.options-common-server-specific.active-directory">
  431. <title>Options for Active Directory</title>
  432. <para>
  433. For ADS, the following options are noteworthy:
  434. <table id="zend.auth.adapter.ldap.options-common-server-specific.active-directory.table">
  435. <title>Options for Active Directory</title>
  436. <tgroup cols="2">
  437. <thead>
  438. <row>
  439. <entry>Name</entry>
  440. <entry>Additional Notes</entry>
  441. </row>
  442. </thead>
  443. <tbody>
  444. <row>
  445. <entry><emphasis role="strong">host</emphasis></entry>
  446. <entry>
  447. As with all servers, this option is required.
  448. </entry>
  449. </row>
  450. <row>
  451. <entry><emphasis role="strong">useStartTls</emphasis></entry>
  452. <entry>
  453. For the sake of security, this should be <code>true</code> if the server has the necessary
  454. certificate installed.
  455. </entry>
  456. </row>
  457. <row>
  458. <entry><emphasis role="strong">useSsl</emphasis></entry>
  459. <entry>
  460. Possibly used as an alternative to <code>useStartTls</code> (see above).
  461. </entry>
  462. </row>
  463. <row>
  464. <entry><emphasis role="strong">baseDn</emphasis></entry>
  465. <entry>
  466. As with all servers, this option is required. By default AD places all user accounts under
  467. the <emphasis>Users</emphasis> container (e.g.,
  468. <emphasis>CN=Users,DC=foo,DC=net</emphasis>), but the default is not common in larger
  469. organizations. Ask your AD administrator what the best DN for accounts for your application
  470. would be.
  471. </entry>
  472. </row>
  473. <row>
  474. <entry><emphasis role="strong">accountCanonicalForm</emphasis></entry>
  475. <entry>
  476. You almost certainly want this to be 3 for backslash style names (e.g.,
  477. <emphasis>FOO\alice</emphasis>), which are most familiar to Windows users. You should
  478. <emphasis>not</emphasis> use the unqualified form 2 (e.g., <emphasis>alice</emphasis>), as
  479. this may grant access to your application to users with the same username in other trusted
  480. domains (e.g., <emphasis>BAR\alice</emphasis> and <emphasis>FOO\alice</emphasis> will be
  481. treated as the same user). (See also note below.)
  482. </entry>
  483. </row>
  484. <row>
  485. <entry><emphasis role="strong">accountDomainName</emphasis></entry>
  486. <entry>
  487. This is required with AD unless <emphasis role="strong">accountCanonicalForm</emphasis> 2
  488. is used, which, again, is discouraged.
  489. </entry>
  490. </row>
  491. <row>
  492. <entry><emphasis role="strong">accountDomainNameShort</emphasis></entry>
  493. <entry>
  494. The NetBIOS name of the domain that users are in and for which the AD server is an authority.
  495. This is required if the backslash style
  496. <emphasis role="strong">accountCanonicalForm</emphasis> is used.
  497. </entry>
  498. </row>
  499. </tbody>
  500. </tgroup>
  501. </table>
  502. </para>
  503. <note>
  504. <para>
  505. Technically there should be no danger of accidental cross-domain authentication with the current
  506. <classname>Zend_Auth_Adapter_Ldap</classname> implementation, since server domains are explicitly checked,
  507. but this may not be true of a future implementation that discovers the domain at runtime, or if an
  508. alternative adapter is used (e.g., Kerberos). In general, account name ambiguity is known to be the
  509. source of security issues, so always try to use qualified account names.
  510. </para>
  511. </note>
  512. </sect3>
  513. <sect3 id="zend.auth.adapter.ldap.options-common-server-specific.openldap">
  514. <title>Options for OpenLDAP</title>
  515. <para>
  516. For OpenLDAP or a generic LDAP server using a typical posixAccount style schema, the following options
  517. are noteworthy:
  518. <table id="zend.auth.adapter.ldap.options-common-server-specific.openldap.table">
  519. <title>Options for OpenLDAP</title>
  520. <tgroup cols="2">
  521. <thead>
  522. <row>
  523. <entry>Name</entry>
  524. <entry>Additional Notes</entry>
  525. </row>
  526. </thead>
  527. <tbody>
  528. <row>
  529. <entry><emphasis role="strong">host</emphasis></entry>
  530. <entry>
  531. As with all servers, this option is required.
  532. </entry>
  533. </row>
  534. <row>
  535. <entry><emphasis role="strong">useStartTls</emphasis></entry>
  536. <entry>
  537. For the sake of security, this should be <code>true</code> if the server has the necessary
  538. certificate installed.
  539. </entry>
  540. </row>
  541. <row>
  542. <entry><emphasis role="strong">useSsl</emphasis></entry>
  543. <entry>
  544. Possibly used as an alternative to <code>useStartTls</code> (see above).
  545. </entry>
  546. </row>
  547. <row>
  548. <entry><emphasis role="strong">username</emphasis></entry>
  549. <entry>
  550. Required and must be a DN, as OpenLDAP requires that usernames be in DN form when
  551. performing a bind. Try to use an unprivileged account.
  552. </entry>
  553. </row>
  554. <row>
  555. <entry><emphasis role="strong">password</emphasis></entry>
  556. <entry>
  557. The password corresponding to the username above, but this may be omitted if the LDAP
  558. server permits an anonymous binding to query user accounts.
  559. </entry>
  560. </row>
  561. <row>
  562. <entry><emphasis role="strong">bindRequiresDn</emphasis></entry>
  563. <entry>
  564. Required and must be <code>true</code>, as OpenLDAP requires that usernames be in DN form
  565. when performing a bind.
  566. </entry>
  567. </row>
  568. <row>
  569. <entry><emphasis role="strong">baseDn</emphasis></entry>
  570. <entry>
  571. As with all servers, this option is required and indicates the DN under which all accounts
  572. being authenticated are located.
  573. </entry>
  574. </row>
  575. <row>
  576. <entry><emphasis role="strong">accountCanonicalForm</emphasis></entry>
  577. <entry>
  578. Optional, but the default value is 4 (principal style names like
  579. <emphasis>alice@foo.net</emphasis>), which may not be ideal if your users are used to
  580. backslash style names (e.g., <emphasis>FOO\alice</emphasis>). For backslash style names use
  581. value 3.
  582. </entry>
  583. </row>
  584. <row>
  585. <entry><emphasis role="strong">accountDomainName</emphasis></entry>
  586. <entry>
  587. Required unless you're using <emphasis role="strong">accountCanonicalForm</emphasis> 2,
  588. which is not recommended.
  589. </entry>
  590. </row>
  591. <row>
  592. <entry><emphasis role="strong">accountDomainNameShort</emphasis></entry>
  593. <entry>
  594. If AD is not also being used, this value is not required. Otherwise, if
  595. <emphasis role="strong">accountCanonicalForm</emphasis> 3 is used, this option is required
  596. and should be a short name that corresponds adequately to the
  597. <emphasis role="strong">accountDomainName</emphasis> (e.g., if your
  598. <emphasis role="strong">accountDomainName</emphasis> is
  599. <emphasis role="strong">foo.net</emphasis>, a good
  600. <emphasis role="strong">accountDomainNameShort</emphasis> value might be
  601. <emphasis>FOO</emphasis>).
  602. </entry>
  603. </row>
  604. </tbody>
  605. </tgroup>
  606. </table>
  607. </para>
  608. </sect3>
  609. </sect2>
  610. </sect1>
  611. <!--
  612. vim:se ts=4 sw=4 et:
  613. -->