1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
<?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>
|