Zend_Ldap-API-Ldap-Dn.xml 14 KB

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