Zend_Ldap-API-Ldap-Attribute.xml 12 KB

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