Zend_Ldap-API-Ldap.xml 28 KB

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