Zend_Ldap_Attribute
Zend_Ldap_Attribute is a helper class providing only static
methods to manipulate arrays suitable to the structure used in
Zend_Ldap data modification methods and to the data format required
by the LDAP server. PHP data types are converted the
following way:
string
No conversion will be done.
integer and float
The value will be converted to a string.
boolean
TRUE will be converted to
'TRUE' and FALSE to
'FALSE'
object and array
The value will be converted to a string by using
serialize().
resource
If a stream resource is given, the data will be
fetched by calling stream_get_contents().
others
All other data types (namely non-stream resources) will be
ommitted.
On reading attribute values the following conversion will take place:
'TRUE'
Converted to TRUE.
'FALSE'
Converted to FALSE.
others
All other strings won't be automatically converted and are passed
as they are.
Zend_Ldap_Attribute API
Method
Description
void setAttribute(array &$data, string
$attribName, mixed $value, boolean $append)
Sets the attribute $attribName in
$data to the value $value. If
$append is TRUE
(FALSE by default) $value will be
appended to the attribute. $value can be a scalar value
or an array of scalar values. Conversion will take place.
array|mixed getAttribute(array $data,
string $attribName, integer|null $index)
Returns the attribute $attribName from
$data. If $index is
NULL (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, NULL will be
returned. Conversion will take place.
boolean attributeHasValue(array &$data,
string $attribName, mixed|array $value)
Checks if the attribute $attribName in
$data has the value(s) given in
$value. The method returns TRUE only
if all values in $value are present in the attribute.
Comparison is done strictly (respecting the data type).
void removeDuplicatesFromAttribute(array
&$data, string $attribName)
Removes all duplicates from the attribute
$attribName in $data.
void removeFromAttribute(array &$data,
string $attribName, mixed|array $value)
Removes the value(s) given in $value from
the attribute $attribName in
$data.
string|null convertToLdapValue(mixed
$value)
Converts a PHP data type into its LDAP
representation. See introduction for details.
mixed convertFromLdapValue(string
$value)
Converts an LDAP value into its PHP
data type. See introduction for details.
string|null
convertToLdapDateTimeValue(integer $value, boolean $utc)
Converts a timestamp into its LDAP date/time
representation. If $utc is TRUE
(FALSE by default) the resulting
LDAP date/time string will be in UTC,
otherwise a local date/time string will be returned.
integer|null
convertFromLdapDateTimeValue(string $value)
Converts LDAP date/time representation into a timestamp.
The method returns NULL if $value
can not be converted back into a PHP timestamp.
void setPassword(array &$data, string
$password, string $hashType, string $attribName)
Sets a LDAP password for the attribute
$attribName in $data.
$attribName defaults to 'userPassword'
which is the standard password attribute. The password hash can be
specified with $hashType. The default value here is
Zend_Ldap_Attribute::PASSWORD_HASH_MD5 with
Zend_Ldap_Attribute::PASSWORD_HASH_SHA as the other
possibilty.
string createPassword(string $password,
string $hashType)
Creates a LDAP password. The password hash can be
specified with $hashType. The default value here is
Zend_Ldap_Attribute::PASSWORD_HASH_MD5 with
Zend_Ldap_Attribute::PASSWORD_HASH_SHA as the other
possibilty.
void setDateTimeAttribute(array &$data,
string $attribName, integer|array $value, boolean $utc, boolean
$append)
Sets the attribute $attribName in
$data to the date/time value $value.
if $append is TRUE
(FALSE by default) $value will be
appended to the attribute. $value can be an integer value
or an array of integers. Date-time-conversion according to
Zend_Ldap_Attribute::convertToLdapDateTimeValue()
will take place.
array|integer getDateTimeAttribute(array
$data, string $attribName, integer|null $index)
Returns the date/time attribute $attribName
from $data. If $index is
NULL (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, NULL will be returned. Date-time-conversion
according to
Zend_Ldap_Attribute::convertFromLdapDateTimeValue()
will take place.