PHP 클래스 Horde_Ldap_Filter, horde

The purpose of this class is to easily build LDAP filters without having to worry about correct escaping etc. A filter is built using several independent filter objects which are combined afterwards. This object works in two modes, depending how the object is created. If the object is created using the {@link create()} method, then this is a leaf-object. If the object is created using the {@link combine()} method, then this is a container object. LDAP filters are defined in RFC 2254.
또한 보기: http://www.ietf.org/rfc/rfc2254.txt A short example: $filter0 = Horde_Ldap_Filter::create('stars', 'equals', '***'); $filter_not0 = Horde_Ldap_Filter::combine('not', $filter0); $filter1 = Horde_Ldap_Filter::create('gn', 'begins', 'bar'); $filter2 = Horde_Ldap_Filter::create('gn', 'ends', 'baz'); $filter_comp = Horde_Ldap_Filter::combine('or', array($filter_not0, $filter1, $filter2)); echo (string)$filter_comp; // This will output: (|(!(stars=\0x5c0x2a\0x5c0x2a\0x5c0x2a))(gn=bar*)(gn=*baz)) // The stars in $filter0 are treaten as real stars unless you disable escaping. Copyright 2009 Benedikt Hallinger Copyright 2010-2016 Horde LLC (http://www.horde.org/)
저자: Benedikt Hallinger ([email protected])
저자: Jan Schneider ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_filter string If this is a leaf filter, the filter representation is store here.
$_filters array This variable holds a array of filter objects that should be combined by this filter object.
$_operator string Operator for sub-filters.

공개 메소드들

메소드 설명
__toString ( ) : string Returns the string representation of this filter.
build ( array $params, string $operator = 'and' ) : Horde_Ldap_Filter Builds a filter (commonly for objectClass attributes) from different configuration options.
combine ( string $operator, array | Horde_Ldap_Filter | string $filters ) : Horde_Ldap_Filter Combines two or more filter objects using a logical operator.
create ( string $attribute, string $match, string $value = '', boolean $escape = true ) : Horde_Ldap_Filter Creates a new part of an LDAP filter.
parse ( string $filter ) : Horde_Ldap_Filter Parses a string into a Horde_Ldap_Filter object.

보호된 메소드들

메소드 설명
__construct ( array $params ) Constructor.
_parseCombination ( string $filter ) : Horde_Ldap_Filter Parses combined subfilter strings.
_parseLeaf ( string $filter ) : Horde_Ldap_Filter Parses a single leaf component.

메소드 상세

__construct() 보호된 메소드

Construction of Horde_Ldap_Filter objects should happen through either {@link create()} or {@link combine()} which give you more control. However, you may use the constructor if you already have generated filters.
protected __construct ( array $params )
$params array List of object parameters

__toString() 공개 메소드

This method runs through all filter objects and creates the string representation of the filter.
public __toString ( ) : string
리턴 string

_parseCombination() 보호된 정적인 메소드

Passes subfilters to parse() and combines the objects using the logical operator detected. Each subfilter could be an arbitary complex subfilter.
protected static _parseCombination ( string $filter ) : Horde_Ldap_Filter
$filter string An LDAP filter string.
리턴 Horde_Ldap_Filter

_parseLeaf() 보호된 정적인 메소드

Parses a single leaf component.
protected static _parseLeaf ( string $filter ) : Horde_Ldap_Filter
$filter string An LDAP filter string.
리턴 Horde_Ldap_Filter

build() 공개 정적인 메소드

Builds a filter (commonly for objectClass attributes) from different configuration options.
public static build ( array $params, string $operator = 'and' ) : Horde_Ldap_Filter
$params array Hash with configuration options that build the search filter. Possible hash keys: - 'filter': An LDAP filter string. - 'objectclass' (string): An objectClass name. - 'objectclass' (array): A list of objectClass names.
$operator string How to combine mutliple 'objectclass' entries. 'and' or 'or'.
리턴 Horde_Ldap_Filter A filter matching the specified criteria.

combine() 공개 정적인 메소드

Example: $filter = Horde_Ldap_Filter::combine('or', array($filter1, $filter2)); If the array contains filter strings instead of filter objects, they will be parsed.
public static combine ( string $operator, array | Horde_Ldap_Filter | string $filters ) : Horde_Ldap_Filter
$operator string The logical operator, either "and", "or", "not" or the logical equivalents "&", "|", "!".
$filters array | Horde_Ldap_Filter | string Array with Horde_Ldap_Filter objects and/or strings or a single filter when using the "not" operator.
리턴 Horde_Ldap_Filter

create() 공개 정적인 메소드

The following matching rules exists: - equals: One of the attributes values is exactly $value. Please note that case sensitiviness depends on the attributes syntax configured in the server. - begins: One of the attributes values must begin with $value. - ends: One of the attributes values must end with $value. - contains: One of the attributes values must contain $value. - present | any: The attribute can contain any value but must exist. - greater: The attributes value is greater than $value. - less: The attributes value is less than $value. - greaterOrEqual: The attributes value is greater or equal than $value. - lessOrEqual: The attributes value is less or equal than $value. - approx: One of the attributes values is similar to $value. If $escape is set to true then $value will be escaped. If set to false then $value will be treaten as a raw filter value string. You should then escape it yourself using {@link Horde_Ldap_Util::escapeFilterValue()}. Examples: This will find entries that contain an attribute "sn" that ends with "foobar": $filter = Horde_Ldap_Filter::create('sn', 'ends', 'foobar'); This will find entries that contain an attribute "sn" that has any value set: $filter = Horde_Ldap_Filter::create('sn', 'any');
public static create ( string $attribute, string $match, string $value = '', boolean $escape = true ) : Horde_Ldap_Filter
$attribute string Name of the attribute the filter should apply to.
$match string Matching rule (equals, begins, ends, contains, greater, less, greaterOrEqual, lessOrEqual, approx, any).
$value string If given, then this is used as a filter value.
$escape boolean Should $value be escaped?
리턴 Horde_Ldap_Filter

parse() 공개 정적인 메소드

Parses a string into a Horde_Ldap_Filter object.
public static parse ( string $filter ) : Horde_Ldap_Filter
$filter string An LDAP filter string.
리턴 Horde_Ldap_Filter

프로퍼티 상세

$_filter 보호되어 있는 프로퍼티

If this is a leaf filter, the filter representation is store here.
protected string $_filter
리턴 string

$_filters 보호되어 있는 프로퍼티

This variable holds a array of filter objects that should be combined by this filter object.
protected array $_filters
리턴 array

$_operator 보호되어 있는 프로퍼티

Operator for sub-filters.
protected string $_operator
리턴 string