| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect3 id="zend.ldap.api.reference.zend-ldap-attribute">
- <title>Zend_Ldap_Attribute</title>
- <para>
- <classname>Zend_Ldap_Attribute</classname> is a helper class providing only static
- methods to manipulate arrays suitable to the structure used in
- <classname>Zend_Ldap</classname> data modification methods and to the data format required
- by the <acronym>LDAP</acronym> server. <acronym>PHP</acronym> data types are converted the
- following way:
- </para>
- <variablelist>
- <varlistentry>
- <term><code>string</code></term>
- <listitem><para>No conversion will be done.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term><code>integer</code> and <code>float</code></term>
- <listitem><para>The value will be converted to a string.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term><code>boolean</code></term>
- <listitem><para><constant>TRUE</constant> will be converted to
- <emphasis>'<constant>TRUE</constant>'</emphasis> and <constant>FALSE</constant> to
- <emphasis>'<constant>FALSE</constant>'</emphasis></para></listitem>
- </varlistentry>
- <varlistentry>
- <term><code>object</code> and <code>array</code></term>
- <listitem><para>The value will be converted to a string by using
- <methodname>serialize()</methodname>.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term><code>resource</code></term>
- <listitem><para>If a <code>stream</code> resource is given, the data will be
- fetched by calling <methodname>stream_get_contents()</methodname>.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term>others</term>
- <listitem><para>All other data types (namely non-stream resources) will be
- ommitted.</para></listitem>
- </varlistentry>
- </variablelist>
- <para>On reading attribute values the following conversion will take place:</para>
- <variablelist>
- <varlistentry>
- <term><emphasis>'<constant>TRUE</constant>'</emphasis></term>
- <listitem><para>Converted to <constant>TRUE</constant>.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term><emphasis>'<constant>FALSE</constant>'</emphasis></term>
- <listitem><para>Converted to <constant>FALSE</constant>.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term>others</term>
- <listitem><para>All other strings won't be automatically converted and are passed
- as they are.</para></listitem>
- </varlistentry>
- </variablelist>
- <table id="zend.ldap.api.reference.zend-ldap-attribute.table">
- <title>Zend_Ldap_Attribute API</title>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>Method</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <emphasis><code>void setAttribute(array &$data, string
- $attribName, mixed $value, boolean $append)</code>
- </emphasis>
- </entry>
- <entry>
- Sets the attribute <varname>$attribName</varname> in
- <varname>$data</varname> to the value <varname>$value</varname>. If
- <varname>$append</varname> is <constant>TRUE</constant>
- (<constant>FALSE</constant> by default) <varname>$value</varname> will be
- appended to the attribute. <varname>$value</varname> can be a scalar value
- or an array of scalar values. Conversion will take place.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>array|mixed getAttribute(array $data,
- string $attribName, integer|null $index)</code> </emphasis>
- </entry>
- <entry>
- Returns the attribute <varname>$attribName</varname> from
- <varname>$data</varname>. If <varname>$index</varname> is
- <constant>NULL</constant> (default) an array will be returned containing all
- the values for the given attribute. An empty array will be returned if the
- attribute does not exist in the given array. If an integer index is
- specified the corresponding value at the given index will be
- returned. If the index is out of bounds, <constant>NULL</constant> will be
- returned. Conversion will take place.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>boolean attributeHasValue(array &$data,
- string $attribName, mixed|array $value)</code> </emphasis>
- </entry>
- <entry>
- Checks if the attribute <varname>$attribName</varname> in
- <varname>$data</varname> has the value(s) given in
- <varname>$value</varname>. The method returns <constant>TRUE</constant> only
- if all values in <varname>$value</varname> are present in the attribute.
- Comparison is done strictly (respecting the data type).
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>void removeDuplicatesFromAttribute(array
- &$data, string $attribName)</code> </emphasis>
- </entry>
- <entry>
- Removes all duplicates from the attribute
- <varname>$attribName</varname> in <varname>$data</varname>.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>void removeFromAttribute(array &$data,
- string $attribName, mixed|array $value)</code> </emphasis>
- </entry>
- <entry>
- Removes the value(s) given in <varname>$value</varname> from
- the attribute <varname>$attribName</varname> in
- <varname>$data</varname>.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>string|null convertToLdapValue(mixed
- $value)</code> </emphasis>
- </entry>
- <entry>
- Converts a <acronym>PHP</acronym> data type into its <acronym>LDAP</acronym>
- representation. See introduction for details.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>mixed convertFromLdapValue(string
- $value)</code> </emphasis>
- </entry>
- <entry>
- Converts an <acronym>LDAP</acronym> value into its <acronym>PHP</acronym>
- data type. See introduction for details.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>string|null
- convertToLdapDateTimeValue(integer $value, boolean $utc)</code>
- </emphasis>
- </entry>
- <entry>
- Converts a timestamp into its <acronym>LDAP</acronym> date/time
- representation. If <varname>$utc</varname> is <constant>TRUE</constant>
- (<constant>FALSE</constant> by default) the resulting
- <acronym>LDAP</acronym> date/time string will be in <acronym>UTC</acronym>,
- otherwise a local date/time string will be returned.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>integer|null
- convertFromLdapDateTimeValue(string $value)</code>
- </emphasis>
- </entry>
- <entry>
- Converts <acronym>LDAP</acronym> date/time representation into a timestamp.
- The method returns <constant>NULL</constant> if <varname>$value</varname>
- can not be converted back into a <acronym>PHP</acronym> timestamp.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>void setPassword(array &$data, string
- $password, string $hashType, string $attribName)</code>
- </emphasis>
- </entry>
- <entry>
- Sets a <acronym>LDAP</acronym> password for the attribute
- <varname>$attribName</varname> in <varname>$data</varname>.
- <varname>$attribName</varname> defaults to <code>'userPassword'</code>
- which is the standard password attribute. The password hash can be
- specified with <varname>$hashType</varname>. The default value here is
- <constant>Zend_Ldap_Attribute::PASSWORD_HASH_MD5</constant> with
- <constant>Zend_Ldap_Attribute::PASSWORD_HASH_SHA</constant> as the other
- possibilty.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>string createPassword(string $password,
- string $hashType)</code> </emphasis>
- </entry>
- <entry>
- Creates a <acronym>LDAP</acronym> password. The password hash can be
- specified with <varname>$hashType</varname>. The default value here is
- <constant>Zend_Ldap_Attribute::PASSWORD_HASH_MD5</constant> with
- <constant>Zend_Ldap_Attribute::PASSWORD_HASH_SHA</constant> as the other
- possibilty.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>void setDateTimeAttribute(array &$data,
- string $attribName, integer|array $value, boolean $utc, boolean
- $append)</code> </emphasis>
- </entry>
- <entry>
- Sets the attribute <varname>$attribName</varname> in
- <varname>$data</varname> to the date/time value <varname>$value</varname>.
- if <varname>$append</varname> is <constant>TRUE</constant>
- (<constant>FALSE</constant> by default) <varname>$value</varname> will be
- appended to the attribute. <varname>$value</varname> can be an integer value
- or an array of integers. Date-time-conversion according to
- <methodname>Zend_Ldap_Attribute::convertToLdapDateTimeValue()</methodname>
- will take place.
- </entry>
- </row>
- <row>
- <entry>
- <emphasis><code>array|integer getDateTimeAttribute(array
- $data, string $attribName, integer|null $index)</code>
- </emphasis>
- </entry>
- <entry>
- Returns the date/time attribute <varname>$attribName</varname>
- from <varname>$data</varname>. If <varname>$index</varname> is
- <constant>NULL</constant> (default) an array will be returned containing
- all the date/time values for the given attribute. An empty array
- will be returned if the attribute does not exist in the given
- array. If an integer index is specified the corresponding date/time
- value at the given index will be returned. If the index is out of
- bounds, <constant>NULL</constant> will be returned. Date-time-conversion
- according to
- <methodname>Zend_Ldap_Attribute::convertFromLdapDateTimeValue()</methodname>
- will take place.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
|