Zend_Ldap-API-Ldap-Attribute.xml 13 KB

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