Net_LDAP
[ class tree: Net_LDAP ] [ index: Net_LDAP ] [ all elements ]

Class: Net_LDAP_Filter

Source Location: /Net_LDAP-0.7.2/LDAP/Filter.php

Class Overview

PEAR
   |
   --Net_LDAP_Filter

Object representation of a part of a LDAP filter.


Author(s):

Version:

  • $Revision: 1.4 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 65]
Object representation of a part of a LDAP filter.

This Class is not completely compatible to the PERL interface!

The purpose of this class is, that users can easily build LDAP filters without having to worry about right 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 create() method, then this is a leaf-object. If the object is created using the combine() method, then this is a container object.

LDAP filters are defined in RFC-2254 and can be found under http://www.ietf.org/rfc/rfc2254.txt

Here a quick copy&paste example:

  1.  $filter0 Net_LDAP_Filter::create('stars''equals''***');
  2.  $filter_not0 Net_LDAP_Filter::combine('not'$filter0);
  3.  
  4.  $filter1 Net_LDAP_Filter::create('gn''begins''bar');
  5.  $filter2 Net_LDAP_Filter::create('gn''ends''baz');
  6.  $filter_comp Net_LDAP_Filter::combine('or',array($filter_not0$filter1$filter2));
  7.  
  8.  echo $filter_comp->asString();
  9.  // This will output: (|(!(stars=\0x5c0x2a\0x5c0x2a\0x5c0x2a))(gn=bar*)(gn=*baz))
  10.  // The stars in $filter0 are treaten as real stars unless you disable escaping.

  • Author: Benedikt Hallinger <beni@php.net>
  • Version: $Revision: 1.4 $


[ Top ]


Method Detail

asString   [line 254]

string asString( )

Get the string representation of this filter

This method runs through all filter objects and creates the string representation of the filter. If this filter object is a leaf filter, then it will return the string representation of this filter.


[ Top ]

as_string   [line 273]

void as_string( )

Alias for perl interface as_string()

[ Top ]

combine   [line 202]

Net_LDAP_Filter|Net_LDAP_Error &combine( string $log_op, array|Net_LDAP_Filter $filters)

Combine two or more filter objects using a logical operator

This static method combines two or more filter objects and returns one single filter object that contains all the others. Call this method statically: $filter =& Net_LDAP_Filter('or', array($filter1, $filter2))


Parameters:

string   $log_op   —  The locicall operator. May be "and", "or", "not" or the subsequent logical equivalents "&", "|", "!"
array|Net_LDAP_Filter   $filters   —  array with Net_LDAP_Filter objects

[ Top ]

create   [line 147]

Net_LDAP_Filter|Net_LDAP_Error &create( string $attr_name, string $match, [string $value = ''], [boolean $escape = true])

Constructor of a new part of a LDAP filter.

The following matching rules exists:

  • equals: One of the attributes values is exactly $value Please note that case sensitiviness is 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
  • any: The attribute can contain any value but must be existent
  • 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 (default) then Wildcards in the value will be escaped properly. If it is set to false then $value will be treaten as raw value.

Examples: $filter = new Net_LDAP_Filter('sn', 'ends', 'foobar'); -> This will find entries that contain a attribute "sn" that ends with "foobar". $filter = new Net_LDAP_Filter('sn', 'any'); -> This will find entries that contain a attribute "sn" that has any value set.


Parameters:

string   $attr_name   —  Name of the attribute the filter should apply to
string   $match   —  Matching rule (equals, begins, ends, contains, greater, less, greaterOrEqual, lessOrEqual, approx, any)
string   $value   —  (optional) if given, then this is used as a filter
boolean   $escape   —  Should the whole $value be escaped? (default: yes, see escape() for detailed information)

[ Top ]

escape   [line 291]

string escape( string $string)

This can be used to escape a string to provide a valid LDAP-Filter.

LDAP will only recognise certain characters as the character istself if it is properly escaped. This is what this method does. The method can be called statically, so you can use it outside for your own purposes (eg for escaping only parts of strings)

  • Return: The string $string, but escaped

Parameters:

string   $string   —  Any string who should be escaped

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:01:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.