PHP 클래스 LdapTools\Utilities\LdapUtilities

저자: Chad Sikorra ([email protected])
파일 보기 프로젝트 열기: ldaptools/ldaptools 1 사용 예제들

공개 메소드들

메소드 설명
encode ( string $value, string $toEncoding ) : string Encode a string for LDAP with a specific encoding type.
escapeValue ( mixed $value, null | string $ignore = null, null | integer $flags = null ) : string Escape any special characters for LDAP to their hexadecimal representation.
explodeDn ( string $dn, integer $withAttributes = 1 ) : array Converts a string distinguished name into its separate pieces.
getAliasAndAttribute ( string $attribute ) : array Given an attribute, split it between its alias and attribute. This will return an array where the first value is the alias and the second is the attribute name. If there is no alias then the first value will be null.
getLdapServersForDomain ( string $domain ) : string[] Get an array of all the LDAP servers for a domain by querying DNS.
getLdapSslCertificates ( string $server, integer $port = 389 ) : array Get an array containing the SSL certificates of the LDAP server. This runs over the standard LDAP port and initiates a TlsStart operation.
getRdnFromDn ( string $dn ) : string Given a full escaped DN return the RDN in escaped form.
implodeDn ( array $dn ) : string Given a DN as an array in ['cn=Name', 'ou=Employees', 'dc=example', 'dc=com'] form, return it as its string representation that is safe to pass back to a query or to save back to LDAP for a DN.
isBinary ( string $value ) : boolean Check if a string contains non-printable, and likely binary, data. There is no easy way to do this, as there can really only be a best effort attempt to detect it.
isValidAttributeFormat ( string $value ) : boolean Determine whether a value is a valid attribute name or OID. The name should meet the format described in RFC 2252.
isValidGuid ( string $value ) : boolean Determine whether a value is in valid GUID format.
isValidLdapObjectDn ( string $dn ) : boolean Given a string, try to determine if it is a valid distinguished name for a LDAP object. This is a somewhat unsophisticated approach. A regex might be a better solution, but would probably be rather difficult to get right.
isValidSid ( string $value ) : boolean Determine whether a value is in SID format.
sanitizeAttributeArray ( array $attributes ) : array Sanitizes certain values in an attribute key => value array to make them safe for logging (ie. mask passwords, replace binary data).
sanitizeBatchArray ( array $batches ) : array Sanitizes certain values in a batch array to make them safe for logging (ie. mask passwords, replace binary data).
unescapeValue ( string $value ) : string Un-escapes a value from its hexadecimal form back to its string representation.
uuid4 ( ) : string Generate a UUIDv4 string.

메소드 상세

encode() 공개 정적인 메소드

Encode a string for LDAP with a specific encoding type.
public static encode ( string $value, string $toEncoding ) : string
$value string The value to encode.
$toEncoding string The encoding type to use (ie. UTF-8)
리턴 string The encoded value.

escapeValue() 공개 정적인 메소드

Escape any special characters for LDAP to their hexadecimal representation.
public static escapeValue ( mixed $value, null | string $ignore = null, null | integer $flags = null ) : string
$value mixed The value to escape.
$ignore null | string The characters to ignore.
$flags null | integer The context for the escaped string. LDAP_ESCAPE_FILTER or LDAP_ESCAPE_DN.
리턴 string The escaped value.

explodeDn() 공개 정적인 메소드

Converts a string distinguished name into its separate pieces.
public static explodeDn ( string $dn, integer $withAttributes = 1 ) : array
$dn string
$withAttributes integer Set to 0 to get the attribute names along with the value.
리턴 array

getAliasAndAttribute() 공개 정적인 메소드

ie. list($alias, $attribute) = LdapUtilities::getAliasAndAttribute($attribute);
public static getAliasAndAttribute ( string $attribute ) : array
$attribute string
리턴 array

getLdapServersForDomain() 공개 정적인 메소드

Get an array of all the LDAP servers for a domain by querying DNS.
public static getLdapServersForDomain ( string $domain ) : string[]
$domain string The domain name to query.
리턴 string[]

getLdapSslCertificates() 공개 정적인 메소드

Get an array containing the SSL certificates of the LDAP server. This runs over the standard LDAP port and initiates a TlsStart operation.
public static getLdapSslCertificates ( string $server, integer $port = 389 ) : array
$server string The server name to connect to
$port integer The standard LDAP port
리턴 array In the form of ['peer_certificate' => '', 'peer_certificate_chain' => []]

getRdnFromDn() 공개 정적인 메소드

Given a full escaped DN return the RDN in escaped form.
public static getRdnFromDn ( string $dn ) : string
$dn string
리턴 string

implodeDn() 공개 정적인 메소드

Given a DN as an array in ['cn=Name', 'ou=Employees', 'dc=example', 'dc=com'] form, return it as its string representation that is safe to pass back to a query or to save back to LDAP for a DN.
public static implodeDn ( array $dn ) : string
$dn array
리턴 string

isBinary() 공개 정적인 메소드

Check if a string contains non-printable, and likely binary, data. There is no easy way to do this, as there can really only be a best effort attempt to detect it.
public static isBinary ( string $value ) : boolean
$value string
리턴 boolean

isValidAttributeFormat() 공개 정적인 메소드

However, the regex is fairly forgiving for each.
public static isValidAttributeFormat ( string $value ) : boolean
$value string
리턴 boolean

isValidGuid() 공개 정적인 메소드

Determine whether a value is in valid GUID format.
public static isValidGuid ( string $value ) : boolean
$value string
리턴 boolean

isValidLdapObjectDn() 공개 정적인 메소드

Given a string, try to determine if it is a valid distinguished name for a LDAP object. This is a somewhat unsophisticated approach. A regex might be a better solution, but would probably be rather difficult to get right.
public static isValidLdapObjectDn ( string $dn ) : boolean
$dn string
리턴 boolean

isValidSid() 공개 정적인 메소드

Determine whether a value is in SID format.
public static isValidSid ( string $value ) : boolean
$value string
리턴 boolean

sanitizeAttributeArray() 공개 정적인 메소드

Sanitizes certain values in an attribute key => value array to make them safe for logging (ie. mask passwords, replace binary data).
public static sanitizeAttributeArray ( array $attributes ) : array
$attributes array
리턴 array

sanitizeBatchArray() 공개 정적인 메소드

Sanitizes certain values in a batch array to make them safe for logging (ie. mask passwords, replace binary data).
public static sanitizeBatchArray ( array $batches ) : array
$batches array
리턴 array

unescapeValue() 공개 정적인 메소드

Un-escapes a value from its hexadecimal form back to its string representation.
public static unescapeValue ( string $value ) : string
$value string
리턴 string

uuid4() 공개 정적인 메소드

Generate a UUIDv4 string.
public static uuid4 ( ) : string
리턴 string