Zend_Ldap-API-Ldap-Attribute.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.ldap.api.reference.zend-ldap-attribute">
  4. <title>Zend_Ldap_Attribute</title>
  5. <para>
  6. <classname>Zend_Ldap_Attribute</classname> is a helper class providing only static
  7. methods to manipulate arrays suitable to the structure used in
  8. <classname>Zend_Ldap</classname> data modification methods and to the data format required
  9. by the <acronym>LDAP</acronym> server. <acronym>PHP</acronym> data types are converted the
  10. following way:
  11. </para>
  12. <variablelist>
  13. <varlistentry>
  14. <term><code>string</code></term>
  15. <listitem><para>No conversion will be done.</para></listitem>
  16. </varlistentry>
  17. <varlistentry>
  18. <term><code>integer</code> and <code>float</code></term>
  19. <listitem><para>The value will be converted to a string.</para></listitem>
  20. </varlistentry>
  21. <varlistentry>
  22. <term><code>boolean</code></term>
  23. <listitem><para><constant>TRUE</constant> will be converted to
  24. <emphasis>'<constant>TRUE</constant>'</emphasis> and <constant>FALSE</constant> to
  25. <emphasis>'<constant>FALSE</constant>'</emphasis></para></listitem>
  26. </varlistentry>
  27. <varlistentry>
  28. <term><code>object</code> and <code>array</code></term>
  29. <listitem><para>The value will be converted to a string by using
  30. <methodname>serialize()</methodname>.</para></listitem>
  31. </varlistentry>
  32. <varlistentry>
  33. <term><code>resource</code></term>
  34. <listitem><para>If a <code>stream</code> resource is given, the data will be
  35. fetched by calling <methodname>stream_get_contents()</methodname>.</para></listitem>
  36. </varlistentry>
  37. <varlistentry>
  38. <term>others</term>
  39. <listitem><para>All other data types (namely non-stream resources) will be
  40. ommitted.</para></listitem>
  41. </varlistentry>
  42. </variablelist>
  43. <para>On reading attribute values the following conversion will take place:</para>
  44. <variablelist>
  45. <varlistentry>
  46. <term><emphasis>'<constant>TRUE</constant>'</emphasis></term>
  47. <listitem><para>Converted to <constant>TRUE</constant>.</para></listitem>
  48. </varlistentry>
  49. <varlistentry>
  50. <term><emphasis>'<constant>FALSE</constant>'</emphasis></term>
  51. <listitem><para>Converted to <constant>FALSE</constant>.</para></listitem>
  52. </varlistentry>
  53. <varlistentry>
  54. <term>others</term>
  55. <listitem><para>All other strings won't be automatically converted and are passed
  56. as they are.</para></listitem>
  57. </varlistentry>
  58. </variablelist>
  59. <table id="zend.ldap.api.reference.zend-ldap-attribute.table">
  60. <title>Zend_Ldap_Attribute API</title>
  61. <tgroup cols="2">
  62. <thead>
  63. <row>
  64. <entry>Method</entry>
  65. <entry>Description</entry>
  66. </row>
  67. </thead>
  68. <tbody>
  69. <row>
  70. <entry>
  71. <emphasis><code>void setAttribute(array &amp;$data, string
  72. $attribName, mixed $value, boolean $append)</code>
  73. </emphasis>
  74. </entry>
  75. <entry>
  76. Sets the attribute <varname>$attribName</varname> in
  77. <varname>$data</varname> to the value <varname>$value</varname>. If
  78. <varname>$append</varname> is <constant>TRUE</constant>
  79. (<constant>FALSE</constant> by default) <varname>$value</varname> will be
  80. appended to the attribute. <varname>$value</varname> can be a scalar value
  81. or an array of scalar values. Conversion will take place.
  82. </entry>
  83. </row>
  84. <row>
  85. <entry>
  86. <emphasis><code>array|mixed getAttribute(array $data,
  87. string $attribName, integer|null $index)</code> </emphasis>
  88. </entry>
  89. <entry>
  90. Returns the attribute <varname>$attribName</varname> from
  91. <varname>$data</varname>. If <varname>$index</varname> is
  92. <constant>NULL</constant> (default) an array will be returned containing all
  93. the values for the given attribute. An empty array will be returned if the
  94. attribute does not exist in the given array. If an integer index is
  95. specified the corresponding value at the given index will be
  96. returned. If the index is out of bounds, <constant>NULL</constant> will be
  97. returned. Conversion will take place.
  98. </entry>
  99. </row>
  100. <row>
  101. <entry>
  102. <emphasis><code>boolean attributeHasValue(array &amp;$data,
  103. string $attribName, mixed|array $value)</code> </emphasis>
  104. </entry>
  105. <entry>
  106. Checks if the attribute <varname>$attribName</varname> in
  107. <varname>$data</varname> has the value(s) given in
  108. <varname>$value</varname>. The method returns <constant>TRUE</constant> only
  109. if all values in <varname>$value</varname> are present in the attribute.
  110. Comparison is done strictly (respecting the data type).
  111. </entry>
  112. </row>
  113. <row>
  114. <entry>
  115. <emphasis><code>void removeDuplicatesFromAttribute(array
  116. &amp;$data, string $attribName)</code> </emphasis>
  117. </entry>
  118. <entry>
  119. Removes all duplicates from the attribute
  120. <varname>$attribName</varname> in <varname>$data</varname>.
  121. </entry>
  122. </row>
  123. <row>
  124. <entry>
  125. <emphasis><code>void removeFromAttribute(array &amp;$data,
  126. string $attribName, mixed|array $value)</code> </emphasis>
  127. </entry>
  128. <entry>
  129. Removes the value(s) given in <varname>$value</varname> from
  130. the attribute <varname>$attribName</varname> in
  131. <varname>$data</varname>.
  132. </entry>
  133. </row>
  134. <row>
  135. <entry>
  136. <emphasis><code>string|null convertToLdapValue(mixed
  137. $value)</code> </emphasis>
  138. </entry>
  139. <entry>
  140. Converts a <acronym>PHP</acronym> data type into its <acronym>LDAP</acronym>
  141. representation. See introduction for details.
  142. </entry>
  143. </row>
  144. <row>
  145. <entry>
  146. <emphasis><code>mixed convertFromLdapValue(string
  147. $value)</code> </emphasis>
  148. </entry>
  149. <entry>
  150. Converts an <acronym>LDAP</acronym> value into its <acronym>PHP</acronym>
  151. data type. See introduction for details.
  152. </entry>
  153. </row>
  154. <row>
  155. <entry>
  156. <emphasis><code>string|null
  157. convertToLdapDateTimeValue(integer $value, boolean $utc)</code>
  158. </emphasis>
  159. </entry>
  160. <entry>
  161. Converts a timestamp into its <acronym>LDAP</acronym> date/time
  162. representation. If <varname>$utc</varname> is <constant>TRUE</constant>
  163. (<constant>FALSE</constant> by default) the resulting
  164. <acronym>LDAP</acronym> date/time string will be in <acronym>UTC</acronym>,
  165. otherwise a local date/time string will be returned.
  166. </entry>
  167. </row>
  168. <row>
  169. <entry>
  170. <emphasis><code>integer|null
  171. convertFromLdapDateTimeValue(string $value)</code>
  172. </emphasis>
  173. </entry>
  174. <entry>
  175. Converts <acronym>LDAP</acronym> date/time representation into a timestamp.
  176. The method returns <constant>NULL</constant> if <varname>$value</varname>
  177. can not be converted back into a <acronym>PHP</acronym> timestamp.
  178. </entry>
  179. </row>
  180. <row>
  181. <entry>
  182. <emphasis><code>void setPassword(array &amp;$data, string
  183. $password, string $hashType, string $attribName)</code>
  184. </emphasis>
  185. </entry>
  186. <entry>
  187. Sets a <acronym>LDAP</acronym> password for the attribute
  188. <varname>$attribName</varname> in <varname>$data</varname>.
  189. <varname>$attribName</varname> defaults to <code>'userPassword'</code>
  190. which is the standard password attribute. The password hash can be
  191. specified with <varname>$hashType</varname>. The default value here is
  192. <constant>Zend_Ldap_Attribute::PASSWORD_HASH_MD5</constant> with
  193. <constant>Zend_Ldap_Attribute::PASSWORD_HASH_SHA</constant> as the other
  194. possibilty.
  195. </entry>
  196. </row>
  197. <row>
  198. <entry>
  199. <emphasis><code>string createPassword(string $password,
  200. string $hashType)</code> </emphasis>
  201. </entry>
  202. <entry>
  203. Creates a <acronym>LDAP</acronym> password. The password hash can be
  204. specified with <varname>$hashType</varname>. The default value here is
  205. <constant>Zend_Ldap_Attribute::PASSWORD_HASH_MD5</constant> with
  206. <constant>Zend_Ldap_Attribute::PASSWORD_HASH_SHA</constant> as the other
  207. possibilty.
  208. </entry>
  209. </row>
  210. <row>
  211. <entry>
  212. <emphasis><code>void setDateTimeAttribute(array &amp;$data,
  213. string $attribName, integer|array $value, boolean $utc, boolean
  214. $append)</code> </emphasis>
  215. </entry>
  216. <entry>
  217. Sets the attribute <varname>$attribName</varname> in
  218. <varname>$data</varname> to the date/time value <varname>$value</varname>.
  219. if <varname>$append</varname> is <constant>TRUE</constant>
  220. (<constant>FALSE</constant> by default) <varname>$value</varname> will be
  221. appended to the attribute. <varname>$value</varname> can be an integer value
  222. or an array of integers. Date-time-conversion according to
  223. <methodname>Zend_Ldap_Attribute::convertToLdapDateTimeValue()</methodname>
  224. will take place.
  225. </entry>
  226. </row>
  227. <row>
  228. <entry>
  229. <emphasis><code>array|integer getDateTimeAttribute(array
  230. $data, string $attribName, integer|null $index)</code>
  231. </emphasis>
  232. </entry>
  233. <entry>
  234. Returns the date/time attribute <varname>$attribName</varname>
  235. from <varname>$data</varname>. If <varname>$index</varname> is
  236. <constant>NULL</constant> (default) an array will be returned containing
  237. all the date/time values for the given attribute. An empty array
  238. will be returned if the attribute does not exist in the given
  239. array. If an integer index is specified the corresponding date/time
  240. value at the given index will be returned. If the index is out of
  241. bounds, <constant>NULL</constant> will be returned. Date-time-conversion
  242. according to
  243. <methodname>Zend_Ldap_Attribute::convertFromLdapDateTimeValue()</methodname>
  244. will take place.
  245. </entry>
  246. </row>
  247. </tbody>
  248. </tgroup>
  249. </table>
  250. </sect3>