Ldap/Converter.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Ldap
- Version
- $Id: Converter.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Ldap_Converter
Zend_Ldap_Converter is a collection of useful LDAP related conversion functions.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Methods


ascToHex32(string $string) : string
Converts all ASCII chars < 32 to "\HEX"
Name | Type | Description |
---|---|---|
$string | string | String to convert |
Type | Description |
---|---|
string |
- Author
- Benedikt Hallinger
- Link
- http://pear.php.net/package/Net_LDAP2
- See
- \global\Net_LDAP2_Util::asc2hex32()


fromLdap(string $value, $type = self::STANDARD, boolean $dateTimeAsUtc = true) : mixed
Convert an LDAP-compatible value to a corresponding PHP-value.
By setting the $type-parameter the conversion of a certain type can be forced .
Name | Type | Description |
---|---|---|
$value | string | The value to convert |
$type | ||
$dateTimeAsUtc | boolean | Return DateTime values in UTC timezone |
Type | Description |
---|---|
mixed |
Exception | Description |
---|---|
\Zend_Ldap_Converter_Exception |


fromLdapBoolean(string $value) : boolean
Convert an LDAP-compatible boolean value into a PHP-compatible one
Name | Type | Description |
---|---|---|
$value | string | The value to convert |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\InvalidArgumentException |


fromLdapDateTime(string $date, boolean $asUtc = true) : \DateTime
Convert an LDAP-Generalized-Time-entry into a DateTime-Object
CAVEAT: The DateTime-Object returned will alwasy be set to UTC-Timezone.
Name | Type | Description |
---|---|---|
$date | string | The generalized-Time |
$asUtc | boolean | Return the DateTime with UTC timezone |
Type | Description |
---|---|
\DateTime |
Exception | Description |
---|---|
\InvalidArgumentException | if a non-parseable-format is given |


fromLdapUnserialize(string $value) : mixed
Unserialize a serialized value to return the corresponding object
Name | Type | Description |
---|---|---|
$value | string | The value to convert |
Type | Description |
---|---|
mixed |
Exception | Description |
---|---|
\UnexpectedValueException |


hex32ToAsc(string $string) : string
Converts all Hex expressions ("\HEX") to their original ASCII characters
Name | Type | Description |
---|---|---|
$string | string | String to convert |
Type | Description |
---|---|
string |
- Author
- Benedikt Hallinger
, heavily based on work from [email protected] - Link
- http://pear.php.net/package/Net_LDAP2
- See
- \global\Net_LDAP2_Util::hex2asc()


toLdap(mixed $value, $type = self::STANDARD) : string
Convert any value to an LDAP-compatible value.
By setting the $type-parameter the conversion of a certain type can be forced
Name | Type | Description |
---|---|---|
$value | mixed | The value to convert |
$type |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Ldap_Converter_Exception |
- Todo
- write more tests


toLdapBoolean(boolean | integer | string $value) : string
Convert a boolean value to an LDAP-compatible string
This converts a boolean value of TRUE, an integer-value of 1 and a case-insensitive string 'true' to an LDAP-compatible 'TRUE'. All other other values are converted to an LDAP-compatible 'FALSE'.
Name | Type | Description |
---|---|---|
$value | boolean | integer | string | The boolean value to encode |
Type | Description |
---|---|
string |


toLdapDateTime(integer | string | \DateTimt | \Zend_Date $date, boolean $asUtc = true) : string
Converts a date-entity to an LDAP-compatible date-string
The date-entity $date can be either a timestamp, a DateTime Object, a string that is parseable by strtotime() or a Zend_Date Object.
Name | Type | Description |
---|---|---|
$date | integer | string | \DateTimt | \Zend_Date | The date-entity |
$asUtc | boolean | Whether to return the LDAP-compatible date-string as UTC or as local value |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\InvalidArgumentException |