Zend_Ldap-API-Ldap-Dn.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.ldap.api.reference.zend-ldap-dn">
  4. <title>Zend_Ldap_Dn</title>
  5. <para>
  6. <classname>Zend_Ldap_Dn</classname> provides an object-oriented interface to
  7. manipulating <acronym>LDAP</acronym> distinguished names (DN). The parameter
  8. <varname>$caseFold</varname> that is used in several methods determines the way DN
  9. attributes are handled regarding their case. Allowed values for this paraneter are:
  10. </para>
  11. <variablelist>
  12. <varlistentry>
  13. <term><constant>Zend_Ldap_Dn::ATTR_CASEFOLD_NONE</constant></term>
  14. <listitem><para>No case-folding will be done.</para></listitem>
  15. </varlistentry>
  16. <varlistentry>
  17. <term><constant>Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER</constant></term>
  18. <listitem><para>All attributes will be converted to upper-case.</para></listitem>
  19. </varlistentry>
  20. <varlistentry>
  21. <term><constant>Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER</constant></term>
  22. <listitem><para>All attributes will be converted to lower-case.</para></listitem>
  23. </varlistentry>
  24. </variablelist>
  25. <para>
  26. The default case-folding is <constant>Zend_Ldap_Dn::ATTR_CASEFOLD_NONE</constant> and
  27. can be set with <methodname>Zend_Ldap_Dn::setDefaultCaseFold()</methodname>. Each instance
  28. of <classname>Zend_Ldap_Dn</classname> can have its own case-folding-setting. If the
  29. <varname>$caseFold</varname> parameter is ommitted in method-calls it defaults to the
  30. instance's case-folding setting.
  31. </para>
  32. <para>
  33. The class implements <code>ArrayAccess</code> to allow indexer-access to the
  34. different parts of the DN. The <code>ArrayAccess</code>-methods proxy to
  35. <methodname>Zend_Ldap_Dn::get($offset, 1, null)</methodname> for <code>offsetGet(integer
  36. $offset)</code>, to <methodname>Zend_Ldap_Dn::set($offset, $value)</methodname> for
  37. <methodname>offsetSet()</methodname> and to
  38. <methodname>Zend_Ldap_Dn::remove($offset, 1)</methodname> for
  39. <methodname>offsetUnset()</methodname>. <methodname>offsetExists()</methodname> simply
  40. checks if the index is within the bounds.
  41. </para>
  42. <table id="zend.ldap.api.reference.zend-ldap-dn.table">
  43. <title>Zend_Ldap_Dn API</title>
  44. <tgroup cols="2">
  45. <thead>
  46. <row>
  47. <entry>Method</entry>
  48. <entry>Description</entry>
  49. </row>
  50. </thead>
  51. <tbody>
  52. <row>
  53. <entry>
  54. <emphasis><code>Zend_Ldap_Dn factory(string|array $dn,
  55. string|null $caseFold)</code> </emphasis>
  56. </entry>
  57. <entry>
  58. Creates a <classname>Zend_Ldap_Dn</classname> instance from an array
  59. or a string. The array must conform to the array structure detailed
  60. under <methodname>Zend_Ldap_Dn::implodeDn()</methodname>.
  61. </entry>
  62. </row>
  63. <row>
  64. <entry>
  65. <emphasis><code>Zend_Ldap_Dn fromString(string $dn,
  66. string|null $caseFold)</code> </emphasis>
  67. </entry>
  68. <entry>
  69. Creates a <classname>Zend_Ldap_Dn</classname> instance from a
  70. string.
  71. </entry>
  72. </row>
  73. <row>
  74. <entry>
  75. <emphasis><code>Zend_Ldap_Dn fromArray(array $dn,
  76. string|null $caseFold)</code> </emphasis>
  77. </entry>
  78. <entry>
  79. Creates a <classname>Zend_Ldap_Dn</classname> instance from an array.
  80. The array must conform to the array structure detailed under
  81. <methodname>Zend_Ldap_Dn::implodeDn()</methodname>.
  82. </entry>
  83. </row>
  84. <row>
  85. <entry><code>array getRdn(string|null $caseFold)</code></entry>
  86. <entry>
  87. Gets the <acronym>RDN</acronym> of the current DN. The return value is an
  88. array with the <acronym>RDN</acronym> attribute names its keys and the
  89. <acronym>RDN</acronym> attribute values.
  90. </entry>
  91. </row>
  92. <row>
  93. <entry><code>string getRdnString(string|null $caseFold)</code></entry>
  94. <entry>
  95. Gets the <acronym>RDN</acronym> of the current DN. The return value is a
  96. string.
  97. </entry>
  98. </row>
  99. <row>
  100. <entry><code>Zend_Ldap_Dn getParentDn(integer $levelUp)</code></entry>
  101. <entry>
  102. Gets the DN of the current DN's ancestor
  103. <varname>$levelUp</varname> levels up the tree. <varname>$levelUp</varname>
  104. defaults to <code>1</code>.
  105. </entry>
  106. </row>
  107. <row>
  108. <entry>
  109. <code>array get(integer $index, integer $length, string|null
  110. $caseFold)</code>
  111. </entry>
  112. <entry>
  113. Returns a slice of the current DN determined by
  114. <varname>$index</varname> and <varname>$length</varname>.
  115. <varname>$index</varname> starts with <code>0</code> on the DN part from the
  116. left.
  117. </entry>
  118. </row>
  119. <row>
  120. <entry><code>Zend_Ldap_Dn set(integer $index, array $value)</code></entry>
  121. <entry>
  122. Replaces a DN part in the current DN. This operation
  123. manipulates the current instance.
  124. </entry>
  125. </row>
  126. <row>
  127. <entry><code>Zend_Ldap_Dn remove(integer $index, integer $length)</code></entry>
  128. <entry>
  129. Removes a DN part from the current DN. This operation
  130. manipulates the current instance. <varname>$length</varname> defaults to
  131. <code>1</code>
  132. </entry>
  133. </row>
  134. <row>
  135. <entry><code>Zend_Ldap_Dn append(array $value)</code></entry>
  136. <entry>
  137. Appends a DN part to the current DN. This operation
  138. manipulates the current instance.
  139. </entry>
  140. </row>
  141. <row>
  142. <entry><code>Zend_Ldap_Dn prepend(array $value)</code></entry>
  143. <entry>
  144. Prepends a DN part to the current DN. This operation
  145. manipulates the current instance.
  146. </entry>
  147. </row>
  148. <row>
  149. <entry><code>Zend_Ldap_Dn insert(integer $index, array $value)</code></entry>
  150. <entry>
  151. Inserts a DN part after the index <varname>$index</varname> to the
  152. current DN. This operation manipulates the current
  153. instance.
  154. </entry>
  155. </row>
  156. <row>
  157. <entry><code>void setCaseFold(string|null $caseFold)</code></entry>
  158. <entry>
  159. Sets the case-folding option to the current DN instance. If
  160. <varname>$caseFold</varname> is <constant>NULL</constant> the default
  161. case-folding setting (<constant>Zend_Ldap_Dn::ATTR_CASEFOLD_NONE</constant>
  162. by default or set via
  163. <methodname>Zend_Ldap_Dn::setDefaultCaseFold()</methodname> will be set for
  164. the current instance.
  165. </entry>
  166. </row>
  167. <row>
  168. <entry><code>string toString(string|null $caseFold)</code></entry>
  169. <entry>Returns DN as a string.</entry>
  170. </row>
  171. <row>
  172. <entry><code>array toArray(string|null $caseFold)</code></entry>
  173. <entry>Returns DN as an array.</entry>
  174. </row>
  175. <row>
  176. <entry><code>string __toString()</code></entry>
  177. <entry>
  178. Returns DN as a string - proxies to
  179. <methodname>Zend_Ldap_Dn::toString(null)</methodname>.
  180. </entry>
  181. </row>
  182. <row>
  183. <entry>
  184. <emphasis><code>void setDefaultCaseFold(string
  185. $caseFold)</code> </emphasis>
  186. </entry>
  187. <entry>
  188. Sets the default case-folding option used by all instances
  189. on creation by default. Already existing instances are not affected
  190. by this setting.
  191. </entry>
  192. </row>
  193. <row>
  194. <entry>
  195. <emphasis><code>array escapeValue(string|array
  196. $values)</code> </emphasis>
  197. </entry>
  198. <entry>Escapes a DN value according to <acronym>RFC</acronym> 2253.</entry>
  199. </row>
  200. <row>
  201. <entry>
  202. <emphasis><code>array unescapeValue(string|array
  203. $values)</code> </emphasis>
  204. </entry>
  205. <entry>
  206. Undoes the conversion done by
  207. <methodname>Zend_Ldap_Dn::escapeValue()</methodname>.
  208. </entry>
  209. </row>
  210. <row>
  211. <entry>
  212. <emphasis><code>array explodeDn(string $dn, array
  213. &amp;$keys, array &amp;$vals, string|null $caseFold)</code>
  214. </emphasis>
  215. </entry>
  216. <entry>
  217. <para>
  218. Explodes the DN <varname>$dn</varname> into an array containing
  219. all parts of the given DN. <varname>$keys</varname> optinally receive DN
  220. keys (e.g. CN, OU, DC, ...). <varname>$vals</varname> optionally receive
  221. DN values. The resulting array will be of type
  222. </para>
  223. <programlisting language="php"><![CDATA[
  224. array(
  225. array("cn" => "name1", "uid" => "user"),
  226. array("cn" => "name2"),
  227. array("dc" => "example"),
  228. array("dc" => "org")
  229. )
  230. ]]></programlisting>
  231. <para>
  232. for a DN of <code>cn=name1+uid=user,cn=name2,dc=example,dc=org</code>.
  233. </para>
  234. </entry>
  235. </row>
  236. <row>
  237. <entry>
  238. <emphasis><code>boolean checkDn(string $dn, array
  239. &amp;$keys, array &amp;$vals, string|null $caseFold)</code>
  240. </emphasis>
  241. </entry>
  242. <entry>
  243. Checks if a given DN <varname>$dn</varname> is malformed. If
  244. <varname>$keys</varname> or <varname>$keys</varname> and
  245. <varname>$vals</varname> are given, these arrays will be filled with the
  246. appropriate DN keys and values.
  247. </entry>
  248. </row>
  249. <row>
  250. <entry>
  251. <emphasis><code>string implodeRdn(array $part, string|null
  252. $caseFold)</code> </emphasis>
  253. </entry>
  254. <entry>
  255. Returns a DN part in the form
  256. <code>$attribute=$value</code>
  257. </entry>
  258. </row>
  259. <row>
  260. <entry>
  261. <emphasis><code>string implodeDn(array $dnArray,
  262. string|null $caseFold, string $separator)</code>
  263. </emphasis>
  264. </entry>
  265. <entry>
  266. <para>
  267. Implodes an array in the form delivered by
  268. <methodname>Zend_Ldap_Dn::explodeDn()</methodname> to a DN string.
  269. <varname>$separator</varname> defaults to <code>','</code> but some LDAP
  270. servers also understand <code>';'</code>. <varname>$dnArray</varname>
  271. must of type
  272. </para>
  273. <programlisting language="php"><![CDATA[
  274. array(
  275. array("cn" => "name1", "uid" => "user"),
  276. array("cn" => "name2"),
  277. array("dc" => "example"),
  278. array("dc" => "org")
  279. )
  280. ]]></programlisting>
  281. </entry>
  282. </row>
  283. <row>
  284. <entry>
  285. <emphasis><code>boolean isChildOf(string|Zend_Ldap_Dn
  286. $childDn, string|Zend_Ldap_Dn $parentDn)</code> </emphasis>
  287. </entry>
  288. <entry>
  289. Checks if given <varname>$childDn</varname> is beneath
  290. <varname>$parentDn</varname> subtree.
  291. </entry>
  292. </row>
  293. </tbody>
  294. </tgroup>
  295. </table>
  296. </sect3>