Zend\Ldap\Converter is a collection of useful LDAP related conversion functions.

package Default

 Methods

Converts all ASCII chars < 32 to "\HEX"

ascToHex32(string $string) : string
Static
see from Benedikt Hallinger
link http://pear.php.net/package/Net_LDAP2
author Benedikt Hallinger

Parameters

$string

string

String to convert

Returns

string

Convert an LDAP-compatible value to a corresponding PHP-value.

fromLdap(string $value, integer $type = self::STANDARD, boolean $dateTimeAsUtc = true) : mixed
Static

By setting the $type-parameter the conversion of a certain type can be forced.

see
see
see

Parameters

$value

string

The value to convert

$type

integer

The conversion type to use

$dateTimeAsUtc

boolean

Return DateTime values in UTC timezone

Returns

mixed

Convert an LDAP-compatible boolean value into a PHP-compatible one

fromLdapBoolean(string $value) : boolean
Static

Parameters

$value

string

The value to convert

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException

Returns

boolean

Convert an LDAP-Generalized-Time-entry into a DateTime-Object

fromLdapDateTime(string $date, boolean $asUtc = true) : \DateTime
Static

CAVEAT: The DateTime-Object returned will always be set to UTC-Timezone.

Parameters

$date

string

The generalized-Time

$asUtc

boolean

Return the DateTime with UTC timezone

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException if a non-parseable-format is given

Returns

\DateTime

Unserialize a serialized value to return the corresponding object

fromLdapUnserialize(string $value) : mixed
Static

Parameters

$value

string

The value to convert

Exceptions

\Zend\Ldap\Converter\Exception\UnexpectedValueException

Returns

mixed

Converts all Hex expressions ("\HEX") to their original ASCII characters

hex32ToAsc(string $string) : string
Static

Convert any value to an LDAP-compatible value.

toLdap(mixed $value, integer $type = self::STANDARD) : string | null
Static

By setting the $type-parameter the conversion of a certain type can be forced

Parameters

$value

mixed

The value to convert

$type

integer

The conversion type to use

Exceptions

\Zend\Ldap\Converter\Exception\ConverterException

Returns

stringnull

Convert a boolean value to an LDAP-compatible string

toLdapBoolean(boolean|integer|string $value) : string
Static

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'.

Parameters

$value

booleanintegerstring

The boolean value to encode

Returns

string

Converts a date-entity to an LDAP-compatible date-string

toLdapDateTime(integer|string|\DateTime $date, boolean $asUtc = true) : string
Static

The date-entity $date can be either a timestamp, a DateTime Object, a string that is parseable by strtotime().

Parameters

$date

integerstring\DateTime

The date-entity

$asUtc

boolean

Whether to return the LDAP-compatible date-string as UTC or as local value

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException

Returns

string

Serialize any value for storage in LDAP

toLdapSerialize(mixed $value) : string
Static

Parameters

$value

mixed

The value to serialize

Returns

string

 Constants

 

BOOLEAN

BOOLEAN = 1 
 

GENERALIZED_TIME

GENERALIZED_TIME = 2 
 

STANDARD

STANDARD = 0