Zend_Ldap-API-Ldap.xml 30 KB

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