HumHub Documentation (unofficial)

Converter
in package

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

Table of Contents

Constants

BOOLEAN  = 1
GENERALIZED_TIME  = 2
STANDARD  = 0

Methods

ascToHex32()  : string
Converts all ASCII chars < 32 to "\HEX"
fromLdap()  : mixed
Convert an LDAP-compatible value to a corresponding PHP-value.
fromLdapBoolean()  : bool
Convert an LDAP-compatible boolean value into a PHP-compatible one
fromLdapDateTime()  : DateTime
Convert an LDAP-Generalized-Time-entry into a DateTime-Object
fromLdapUnserialize()  : mixed
Unserialize a serialized value to return the corresponding object
hex32ToAsc()  : string
Converts all Hex expressions ("\HEX") to their original ASCII characters
toLdap()  : string|null
Convert any value to an LDAP-compatible value.
toLdapBoolean()  : string
Convert a boolean value to an LDAP-compatible string
toLdapDateTime()  : string
Converts a date-entity to an LDAP-compatible date-string
toLdapSerialize()  : string
Serialize any value for storage in LDAP

Constants

GENERALIZED_TIME

public mixed GENERALIZED_TIME = 2

Methods

fromLdap()

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

public static fromLdap(string $value[, int $type = self::STANDARD ][, bool $dateTimeAsUtc = true ]) : mixed

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

Parameters
$value : string

The value to convert

$type : int = self::STANDARD

The conversion type to use

$dateTimeAsUtc : bool = true

Return DateTime values in UTC timezone

Tags
see
Converter::STANDARD
see
Converter::BOOLEAN
see
Converter::GENERALIZED_TIME

fromLdapBoolean()

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

public static fromLdapBoolean(string $value) : bool
Parameters
$value : string

The value to convert

Tags
throws
InvalidArgumentException
Return values
bool

fromLdapDateTime()

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

public static fromLdapDateTime(string $date[, bool $asUtc = true ]) : DateTime

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

Parameters
$date : string

The generalized-Time

$asUtc : bool = true

Return the DateTime with UTC timezone

Tags
throws
InvalidArgumentException

If a non-parseable-format is given.

Return values
DateTime

fromLdapUnserialize()

Unserialize a serialized value to return the corresponding object

public static fromLdapUnserialize(string $value) : mixed
Parameters
$value : string

The value to convert

Tags
throws
UnexpectedValueException

hex32ToAsc()

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

public static hex32ToAsc(string $string) : string
Parameters
$string : string

String to convert

Tags
link
http://pear.php.net/package/Net_LDAP2
see
Net_LDAP2_Util::hex2asc()

from Benedikt Hallinger beni@php.net, heavily based on work from DavidSmith@byu.net

Return values
string

toLdap()

Convert any value to an LDAP-compatible value.

public static toLdap(mixed $value[, int $type = self::STANDARD ]) : string|null

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

Parameters
$value : mixed

The value to convert

$type : int = self::STANDARD

The conversion type to use

Tags
throws
ConverterException
Return values
string|null

toLdapBoolean()

Convert a boolean value to an LDAP-compatible string

public static toLdapBoolean(bool|int|string $value) : 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'.

Parameters
$value : bool|int|string

The boolean value to encode

Return values
string

toLdapDateTime()

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

public static toLdapDateTime(int|string|DateTime $date[, bool $asUtc = true ]) : string

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

Parameters
$date : int|string|DateTime

The date-entity

$asUtc : bool = true

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

Tags
throws
InvalidArgumentException
Return values
string

toLdapSerialize()

Serialize any value for storage in LDAP

public static toLdapSerialize(mixed $value) : string
Parameters
$value : mixed

The value to serialize

Return values
string

        
On this page

Search results