Zend_Ldap-API-Ldap.xml 30 KB

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