Zend_Ldap-API-Ldap.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 16831 -->
  3. <!-- Reviewed: no -->
  4. <sect3 id="zend.ldap.api.reference.zend-ldap">
  5. <title>Zend_Ldap</title>
  6. <para>
  7. <classname>Zend_Ldap</classname> is the base interface into a <acronym>LDAP</acronym> server. It provides
  8. connection and binding methods as well as methods to operate on the LDAP
  9. tree.
  10. </para>
  11. <table id="zend.ldap.api.reference.zend-ldap.table">
  12. <title>Zend_Ldap API</title>
  13. <tgroup cols="2">
  14. <thead>
  15. <row>
  16. <entry>Method</entry>
  17. <entry>Description</entry>
  18. </row>
  19. </thead>
  20. <tbody>
  21. <row>
  22. <entry>
  23. <code>string filterEscape(string $str)</code>
  24. </entry>
  25. <entry>
  26. Escapes a value to be used in a <acronym>LDAP</acronym> filter according to RFC
  27. 2254. This method is <emphasis>deprecated</emphasis>, please use
  28. <code>Zend_Ldap_Filter_Abstract::escapeValue()</code>
  29. instead.
  30. </entry>
  31. </row>
  32. <row>
  33. <entry>
  34. <code>boolean explodeDn($dn, array &amp;$keys = null, array &amp;$vals = null)</code>
  35. </entry>
  36. <entry>
  37. Checks if a given DN <code>$dn</code> is malformed. If
  38. <code>$keys</code> or <code>$keys</code> and <code>$vals</code> are
  39. given, these arrays will be filled with the appropriate DN keys and
  40. values. This method is <emphasis>deprecated</emphasis>, please use
  41. <code>Zend_Ldap_Dn::checkDn()</code> instead.
  42. </entry>
  43. </row>
  44. <row>
  45. <entry><code>__construct($options)</code></entry>
  46. <entry>
  47. Constructor. The <code>$options</code> parameter is optional
  48. and can be set to an array or a <classname>Zend_Config</classname> instance.
  49. If no options are provided at instantiation, the connection
  50. parameters must be passed to the instance using
  51. <code>Zend_Ldap::setOptions()</code>. The allowed options are
  52. specified in <link
  53. linkend="zend.ldap.api.configuration.table">Zend_Ldap
  54. Options</link>
  55. </entry>
  56. </row>
  57. <row>
  58. <entry><code>resource getResource()</code></entry>
  59. <entry>Returns the raw <acronym>LDAP</acronym> extension (ext/ldap) resource.</entry>
  60. </row>
  61. <row>
  62. <entry><code>integer getLastErrorCode()</code></entry>
  63. <entry>
  64. Returns the <acronym>LDAP</acronym> error number of the last LDAP
  65. command.
  66. </entry>
  67. </row>
  68. <row>
  69. <entry>
  70. <code>string getLastError(integer &amp;$errorCode, array &amp;$errorMessages)</code>
  71. </entry>
  72. <entry>
  73. Returns the <acronym>LDAP</acronym> error message of the last <acronym>LDAP</acronym> command. The
  74. optional <code>$errorCode</code> parameter is set to the <acronym>LDAP</acronym> error
  75. number when given. The optional <code>$errorMessages</code> array
  76. will be filled with the raw error messages when given. The various
  77. <acronym>LDAP</acronym> error retrieval functions can return different things, so they
  78. are all collected if <code>$errorMessages</code> is given.
  79. </entry>
  80. </row>
  81. <row>
  82. <entry><code>Zend_Ldap setOptions($options)</code></entry>
  83. <entry>
  84. Sets the <acronym>LDAP</acronym> connection and binding parameters.
  85. <code>$options</code> can be an array or an instance of
  86. <classname>Zend_Config</classname>. The allowed options are specified in
  87. <link
  88. linkend="zend.ldap.api.configuration.table">Zend_Ldap Options</link>
  89. </entry>
  90. </row>
  91. <row>
  92. <entry><code>array getOptions()</code></entry>
  93. <entry>
  94. Returns the current connection and binding
  95. parameters.
  96. </entry>
  97. </row>
  98. <row>
  99. <entry><code>string getBaseDn()</code></entry>
  100. <entry>
  101. Returns the base DN this <acronym>LDAP</acronym> connection is bound
  102. to.
  103. </entry>
  104. </row>
  105. <row>
  106. <entry>
  107. <code>string getCanonicalAccountName(string $acctname, integer $form)</code>
  108. </entry>
  109. <entry>
  110. Returns the canonical account name of the given account name
  111. <code>$acctname</code>. <code>$form</code> specifies the <link
  112. linkend="zend.ldap.using.theory-of-operation.account-name-canonicalization.table">format</link>
  113. into which the account name is canonicalized. See <link
  114. linkend="zend.ldap.introduction.theory-of-operations.account-name-canonicalization">Account Name Canonicalization</link>
  115. for more details.
  116. </entry>
  117. </row>
  118. <row>
  119. <entry><code>Zend_Ldap disconnect()</code></entry>
  120. <entry>
  121. Disconnects the Zend_Ldap instance from the LDAP
  122. server.
  123. </entry>
  124. </row>
  125. <row>
  126. <entry>
  127. <code>Zend_Ldap connect(string $host, integer $port, boolean $useSsl, boolean $useStartTls)</code>
  128. </entry>
  129. <entry>
  130. Connects the Zend_Ldap instance to the given <acronym>LDAP</acronym> server.
  131. All parameters are optional and will be taken from the LDAP
  132. connection and binding parameters passed to the instance via the
  133. construtor or via <code>Zend_Ldap::setOptions()</code> when set to
  134. <code>null</code>.
  135. </entry>
  136. </row>
  137. <row>
  138. <entry>
  139. <code>Zend_Ldap bind(string $username, string $password)</code>
  140. </entry>
  141. <entry>
  142. Authenticates <code>$username</code> with
  143. <code>$password</code> at the <acronym>LDAP</acronym> server. If both paramaters are
  144. omitted the binding will be carried out with the credentials given
  145. in the connection and binding parameters. If no credentials are
  146. given in the connection and binding parameters an anonymous bind
  147. will be performed. Note that this requires anonymous binds to be
  148. allowed on the <acronym>LDAP</acronym> server. An empty string <code>''</code> can be
  149. passed as <code>$password</code> together with a username if, and
  150. only if, <code>allowEmptyPassword</code> is set to
  151. <code>true</code> in the connection and binding parameters.
  152. </entry>
  153. </row>
  154. <row>
  155. <entry>
  156. <code>Zend_Ldap_Collection search(string|Zend_Ldap_Filter_Abstract $filter, string|Zend_Ldap_Dn $basedn, integer $scope, array $attributes, string $sort, string $collectionClass)</code>
  157. </entry>
  158. <entry>
  159. Searches the <acronym>LDAP</acronym> tree with the given <code>$filter</code>
  160. and the given search parameters.
  161. <variablelist>
  162. <varlistentry>
  163. <term><code>string|Zend_Ldap_Filter_Abstract
  164. $filter</code></term>
  165. <listitem>
  166. <para>
  167. The filter string to be used in the search, e.g.
  168. <code>(objectClass=posixAccount)</code>.
  169. </para>
  170. </listitem>
  171. </varlistentry>
  172. <varlistentry>
  173. <term><code>string|Zend_Ldap_Dn $basedn</code></term>
  174. <listitem>
  175. <para>
  176. The search base for the search. If omitted or
  177. <code>null</code>, the <code>baseDn</code> from the
  178. connection and binding parameters is used.
  179. </para>
  180. </listitem>
  181. </varlistentry>
  182. <varlistentry>
  183. <term><code>integer $scope</code></term>
  184. <listitem>
  185. <para>
  186. The search scope.
  187. <code>Zend_Ldap::SEARCH_SCOPE_SUB</code> searches the
  188. complete subtree including the <code>$baseDn</code> node.
  189. <code>Zend_Ldap::SEARCH_SCOPE_ONE</code> restricts search
  190. to one level below <code>$baseDn</code>.
  191. <code>Zend_Ldap::SEARCH_SCOPE_BASE</code> restricts search
  192. to the <code>$baseDn</code> itself; this can be used to
  193. efficiently retrieve a single entry by its DN. The default
  194. value is
  195. <code>Zend_Ldap::SEARCH_SCOPE_SUB</code>.
  196. </para>
  197. </listitem>
  198. </varlistentry>
  199. <varlistentry>
  200. <term><code>array $attributes</code></term>
  201. <listitem>
  202. <para>
  203. Specifies the attributes contained in the
  204. returned entries. To include all possible attributes (ACL
  205. restrictions can disallow certain attribute to be retrieved
  206. by a given user) pass either an empty array
  207. <code>array()</code> or <code>array('*')</code> to the
  208. method. On some <acronym>LDAP</acronym> servers you can retrieve special
  209. internal attributes by passing <code>array('*', '+')</code>
  210. to the method.
  211. </para>
  212. </listitem>
  213. </varlistentry>
  214. <varlistentry>
  215. <term><code>string $sort</code></term>
  216. <listitem>
  217. <para>
  218. If given the result collection will be sorted
  219. after the attribute <code>$sort</code>. Results can only be
  220. sorted after one single attribute as this parameter uses
  221. the ext/ldap function <code>ldap_sort()</code>.
  222. </para>
  223. </listitem>
  224. </varlistentry>
  225. <varlistentry>
  226. <term><code>string $collectionClass</code></term>
  227. <listitem>
  228. <para>
  229. If given the result will be wrapped in an object
  230. of type <code>$collectionClass</code>. By default an object
  231. of type <code>Zend_Ldap_Collection</code> will be returned.
  232. The custom class must extend
  233. <code>Zend_Ldap_Collection</code> and will be passed a
  234. <code>Zend_Ldap_Collection_Iterator_Default</code> on
  235. instantiation.
  236. </para>
  237. </listitem>
  238. </varlistentry>
  239. </variablelist>
  240. </entry>
  241. </row>
  242. <row>
  243. <entry>
  244. <code>integer count(string|Zend_Ldap_Filter_Abstract
  245. $filter, string|Zend_Ldap_Dn $basedn, integer
  246. $scope)</code>
  247. </entry>
  248. <entry>
  249. Counts the elements returned by the given search parameters.
  250. See <code>Zend_Ldap::search()</code> for a detailed description of
  251. the method parameters.
  252. </entry>
  253. </row>
  254. <row>
  255. <entry>
  256. <code>integer countChildren(string|Zend_Ldap_Dn
  257. $dn)</code>
  258. </entry>
  259. <entry>
  260. Counts the direct descendants (children) of the entry
  261. identified by the given <code>$dn</code>.
  262. </entry>
  263. </row>
  264. <row>
  265. <entry><code>boolean exists(string|Zend_Ldap_Dn $dn)</code></entry>
  266. <entry>
  267. Checks whether the entry identified by the given
  268. <code>$dn</code> exists.
  269. </entry>
  270. </row>
  271. <row>
  272. <entry>
  273. <code>array searchEntries(string|Zend_Ldap_Filter_Abstract
  274. $filter, string|Zend_Ldap_Dn $basedn, integer $scope, array
  275. $attributes, string $sort)</code>
  276. </entry>
  277. <entry>
  278. Performs a search operation and returns the result as an PHP
  279. array. This is essentially the same method as
  280. <code>Zend_Ldap::search()</code> except for the return type. See
  281. <code>Zend_Ldap::search()</code> for a detailed description of the
  282. method parameters.
  283. </entry>
  284. </row>
  285. <row>
  286. <entry>
  287. <code>array getEntry(string|Zend_Ldap_Dn $dn, array
  288. $attributes, boolean $throwOnNotFound)</code>
  289. </entry>
  290. <entry>
  291. Retrieves the <acronym>LDAP</acronym> entry identified by <code>$dn</code> with
  292. the attributes specified in <code>$attributes</code>. If
  293. <code>$attributes</code> is ommitted, all attributes
  294. (<code>array()</code>) are included in the result.
  295. <code>$throwOnNotFound</code> is <code>false</code> by default, so
  296. the method will return <code>null</code> if the specified entry
  297. cannot be found. If set to <code>true</code>, a
  298. <code>Zend_Ldap_Exception</code> will be thrown instead.
  299. </entry>
  300. </row>
  301. <row>
  302. <entry>
  303. <emphasis><code>void prepareLdapEntryArray(array
  304. &amp;$entry)</code> </emphasis>
  305. </entry>
  306. <entry>
  307. Prepare an array for the use in <acronym>LDAP</acronym> modification
  308. operations. This method does not need to be called by the end-user
  309. as it's implicitly called on every data modification
  310. method.
  311. </entry>
  312. </row>
  313. <row>
  314. <entry>
  315. <code>Zend_Ldap add(string|Zend_Ldap_Dn $dn, array
  316. $entry)</code>
  317. </entry>
  318. <entry>
  319. Adds the entry identified by <code>$dn</code> with its
  320. attributes <code>$entry</code> to the <acronym>LDAP</acronym> tree. Throws a
  321. <code>Zend_Ldap_Exception</code> if the entry could not be
  322. added.
  323. </entry>
  324. </row>
  325. <row>
  326. <entry>
  327. <code>Zend_Ldap update(string|Zend_Ldap_Dn $dn, array
  328. $entry)</code>
  329. </entry>
  330. <entry>
  331. Updates the entry identified by <code>$dn</code> with its
  332. attributes <code>$entry</code> to the <acronym>LDAP</acronym> tree. Throws a
  333. <code>Zend_Ldap_Exception</code> if the entry could not be
  334. modified.
  335. </entry>
  336. </row>
  337. <row>
  338. <entry>
  339. <code>Zend_Ldap save(string|Zend_Ldap_Dn $dn, array
  340. $entry)</code>
  341. </entry>
  342. <entry>
  343. Saves the entry identified by <code>$dn</code> with its
  344. attributes <code>$entry</code> to the <acronym>LDAP</acronym> tree. Throws a
  345. <code>Zend_Ldap_Exception</code> if the entry could not be saved.
  346. This method decides by querying the <acronym>LDAP</acronym> tree if the entry will be
  347. added or updated.
  348. </entry>
  349. </row>
  350. <row>
  351. <entry>
  352. <code>Zend_Ldap delete(string|Zend_Ldap_Dn $dn, boolean
  353. $recursively)</code>
  354. </entry>
  355. <entry>
  356. Deletes the entry identified by <code>$dn</code> from the
  357. <acronym>LDAP</acronym> tree. Throws a <code>Zend_Ldap_Exception</code> if the entry
  358. could not be deleted. <code>$recursively</code> is
  359. <code>false</code> by default. If set to <code>true</code> the
  360. deletion will be carried out recursively and will effectively
  361. delete a complete subtree. Deletion will fail if
  362. <code>$recursively</code> is <code>false</code> and the entry
  363. <code>$dn</code> is not a leaf entry.
  364. </entry>
  365. </row>
  366. <row>
  367. <entry>
  368. <code>Zend_Ldap moveToSubtree(string|Zend_Ldap_Dn $from,
  369. string|Zend_Ldap_Dn $to, boolean $recursively, boolean
  370. $alwaysEmulate)</code>
  371. </entry>
  372. <entry>
  373. Moves the entry identified by <code>$from</code> to a
  374. location below <code>$to</code> keeping its <acronym>RDN</acronym> unchanged.
  375. <code>$recursively</code> specifies if the operation will be
  376. carried out recursively (<code>false</code> by default) so that the
  377. entry <code>$from</code> and all its descendants will be moved.
  378. Moving will fail if <code>$recursively</code> is <code>false</code>
  379. and the entry <code>$from</code> is not a leaf entry.
  380. <code>$alwaysEmulate</code> controls whether the ext/ldap function
  381. <code>ldap_rename()</code> should be used if available. This can
  382. only work for leaf entries and for servers and for ext/ldap
  383. supporting this function. Set to <code>true</code> to always use an
  384. emulated rename operation.
  385. <note>
  386. <para>All move-operations are carried out by copying and then
  387. deleting the corresponding entries in the <acronym>LDAP</acronym> tree. These
  388. operations are not <emphasis>atomic</emphasis> so that failures
  389. during the operation will result in an
  390. <emphasis>inconsistent</emphasis> state on the <acronym>LDAP</acronym> server. The
  391. same is true for all recursive operations. They also are by no
  392. means atomic. Please keep this in mind.
  393. </para>
  394. </note></entry>
  395. </row>
  396. <row>
  397. <entry>
  398. <code>Zend_Ldap move(string|Zend_Ldap_Dn $from,
  399. string|Zend_Ldap_Dn $to, boolean $recursively, boolean
  400. $alwaysEmulate)</code>
  401. </entry>
  402. <entry>
  403. This is an alias for
  404. <code>Zend_Ldap::rename()</code>.
  405. </entry>
  406. </row>
  407. <row>
  408. <entry>
  409. <code>Zend_Ldap rename(string|Zend_Ldap_Dn $from,
  410. string|Zend_Ldap_Dn $to, boolean $recursively, boolean
  411. $alwaysEmulate)</code>
  412. </entry>
  413. <entry>
  414. Renames the entry identified by <code>$from</code> to
  415. <code>$to</code>. <code>$recursively</code> specifies if the
  416. operation will be carried out recursively (<code>false</code> by
  417. default) so that the entry <code>$from</code> and all its
  418. descendants will be moved. Moving will fail if
  419. <code>$recursively</code> is <code>false</code> and the entry
  420. <code>$from</code> is not a leaf entry. <code>$alwaysEmulate</code>
  421. controls whether the ext/ldap function <code>ldap_rename()</code>
  422. should be used if available. This can only work for leaf entries
  423. and for servers and for ext/ldap supporting this function. Set to
  424. <code>true</code> to always use an emulated rename
  425. operation.
  426. </entry>
  427. </row>
  428. <row>
  429. <entry>
  430. <code>Zend_Ldap copyToSubtree(string|Zend_Ldap_Dn $from,
  431. string|Zend_Ldap_Dn $to, boolean $recursively)</code>
  432. </entry>
  433. <entry>
  434. Copies the entry identified by <code>$from</code> to a
  435. location below <code>$to</code> keeping its <acronym>RDN</acronym> unchanged.
  436. <code>$recursively</code> specifies if the operation will be
  437. carried out recursively (<code>false</code> by default) so that the
  438. entry <code>$from</code> and all its descendants will be copied.
  439. Copying will fail if <code>$recursively</code> is
  440. <code>false</code> and the entry <code>$from</code> is not a leaf
  441. entry.
  442. </entry>
  443. </row>
  444. <row>
  445. <entry>
  446. <code>Zend_Ldap copy(string|Zend_Ldap_Dn $from,
  447. string|Zend_Ldap_Dn $to, boolean $recursively)</code>
  448. </entry>
  449. <entry>
  450. Copies the entry identified by <code>$from</code> to
  451. <code>$to</code>. <code>$recursively</code> specifies if the
  452. operation will be carried out recursively (<code>false</code> by
  453. default) so that the entry <code>$from</code> and all its
  454. descendants will be copied. Copying will fail if
  455. <code>$recursively</code> is <code>false</code> and the entry
  456. <code>$from</code> is not a leaf entry.
  457. </entry>
  458. </row>
  459. <row>
  460. <entry>
  461. <code>Zend_Ldap_Node getNode(string|Zend_Ldap_Dn
  462. $dn)</code>
  463. </entry>
  464. <entry>
  465. Returns the entry <code>$dn</code> wrapped in a
  466. <code>Zend_Ldap_Node</code>.
  467. </entry>
  468. </row>
  469. <row>
  470. <entry><code>Zend_Ldap_Node getBaseNode()</code></entry>
  471. <entry>
  472. Returns the entry for the base DN <code>$baseDn</code>
  473. wrapped in a <code>Zend_Ldap_Node</code>.
  474. </entry>
  475. </row>
  476. <row>
  477. <entry><code>Zend_Ldap_Node_RootDse getRootDse()</code></entry>
  478. <entry>Returns the RootDSE for the current server.</entry>
  479. </row>
  480. <row>
  481. <entry><code>Zend_Ldap_Node_Schema getSchema()</code></entry>
  482. <entry>Returns the <acronym>LDAP</acronym> schema for the current server.</entry>
  483. </row>
  484. </tbody>
  485. </tgroup>
  486. </table>
  487. <sect4 id="zend.ldap.api.reference.zend-ldap.zend-ldap-collection">
  488. <title>Zend_Ldap_Collection</title>
  489. <para>
  490. <code>Zend_Ldap_Collection</code> implements <code>Iterator</code> to
  491. allow for item traversal using <code>foreach()</code> and
  492. <code>Countable</code> to be able to respond to <code>count()</code>. With its
  493. protected <code>_createEntry()</code> method it provides a simple extension
  494. point for developers needing custom result objects.
  495. </para>
  496. <table id="zend.ldap.api.reference.zend-ldap.zend-ldap-collection.table">
  497. <title>Zend_Ldap_Collection API</title>
  498. <tgroup cols="2">
  499. <thead>
  500. <row>
  501. <entry>Method</entry>
  502. <entry>Description</entry>
  503. </row>
  504. </thead>
  505. <tbody>
  506. <row>
  507. <entry>
  508. <code>__construct(Zend_Ldap_Collection_Iterator_Interface
  509. $iterator)</code>
  510. </entry>
  511. <entry>
  512. Constructor. The constrcutor must be provided by a
  513. <code>Zend_Ldap_Collection_Iterator_Interface</code> which does the
  514. real result iteration.
  515. <code>Zend_Ldap_Collection_Iterator_Default</code> is the default
  516. implementation for iterating ext/ldap results.
  517. </entry>
  518. </row>
  519. <row>
  520. <entry><code>boolean close()</code></entry>
  521. <entry>
  522. Closes the internal iterator. This is also called in the
  523. destructor.
  524. </entry>
  525. </row>
  526. <row>
  527. <entry><code>array toArray()</code></entry>
  528. <entry>Returns all entries as an array.</entry>
  529. </row>
  530. <row>
  531. <entry><code>array getFirst()</code></entry>
  532. <entry>
  533. Returns the first entry in the collection or
  534. <code>null</code> if the collection is empty.
  535. </entry>
  536. </row>
  537. </tbody></tgroup>
  538. </table>
  539. </sect4>
  540. </sect3>