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

Class: DB_ldap2

Source Location: /DB_ldap2-0.3/ldap2.php

Class Overview

DB_common
   |
   --DB_ldap2

LDAP2 DB interface class


Author(s):

Version:

  • $Revision: 1.4 $

Methods


Child classes:

DB_ldap3
LDAP3 DB interface class

Inherited Variables

Inherited Methods


Class Details

[line 41]
LDAP2 DB interface class

DB_ldap2 extends DB_common to provide DB compliant access to LDAP servers with protocol version 2.



[ Top ]


Method Detail

DB_ldap2 (Constructor)   [line 119]

DB_ldap2 DB_ldap2( )

Constructor, calls DB_common constructor
  • See: DB_common::DB_common()

[ Top ]

affectedRows   [line 638]

int affectedRows( )

Gets the number of rows affected by the last query.

if the last query was a select, returns 0.

  • Return: number of rows affected by the last query or DB_ERROR

[ Top ]

base   [line 690]

void base( [mixed $base_dn = null])

  • Deprecated:

[ Top ]

connect   [line 173]

int connect( $dsn $dsninfo, [boolean $persistent = false])

Connect and bind to LDAPv2 server with either anonymous or authenticated bind depending on dsn info

The format of the supplied DSN:

ldap2://binddn:bindpw@host:port/basedn

I.e.:

ldap2://uid=dexter,ou=People,dc=example,dc=net:secret@127.0.0.1/dc=example,dc=net

  • Return: DB_OK if successfully connected. A DB error code is returned on failure.

Overridden in child classes as:

DB_ldap3::connect()
Connect and bind to LDAPv3 server with either anonymous or authenticated bind depending on dsn info

Parameters:

boolean   $persistent     kept for interface compatibility
$dsn   $dsninfo     the data source name (see DB::parseDSN for syntax)

[ Top ]

createSequence   [line 815]

mixed createSequence( string $seq_name)

Create the sequence

The sequence entry is based on core schema with extensibleObject, so it should work with any LDAP server which doesn't check schema or supports extensibleObject object class.

Format of the entry:

dn: $seq_dn objectClass: top objectClass: extensibleObject sn: $seq_id cn: $seq_value uid: $seq_uniq

  • Return: DB_OK on success or DB error on error

Parameters:

string   $seq_name     the sequence name

[ Top ]

disconnect   [line 232]

int disconnect( )

Unbinds from LDAP server
  • Return: ldap_unbind() return value

[ Top ]

dropSequence   [line 843]

mixed dropSequence( string $seq_name)

Drop a sequence
  • Return: DB_OK on success or DB error on error

Parameters:

string   $seq_name     the sequence name

[ Top ]

errorNative   [line 624]

int errorNative( )

Get the native error code of the last error (if any) that occured on the current connection.
  • Return: native LDAP error code

[ Top ]

executeEmulateQuery   [line 1013]

mixed executeEmulateQuery( resource $stmt, [array $data = false])

Emulates the execute statement.
  • Return: an array containing the real query run when emulating prepare/execute. A DB error code is returned on failure.
  • See: execute()

Parameters:

resource   $stmt     query handle from prepare()
array   $data     numeric array containing the data to insert into the query

[ Top ]

fetchInto   [line 446]

int fetchInto( $result $result, $arr &$arr, $fetchmode $fetchmode, [$rownum $rownum = null])

Fetch a row and insert the data into an existing array.

DB_FETCHMODE_ORDERED returns a flat array of values ("value", "val1", "val2").

DB_FETCHMODE_ASSOC returns an array of structuralized data ("field_name1" => "value", "field_name2" => array("val1", "val2")).

  • Return: DB_OK on success, a DB error code on failure

Parameters:

$result   $result     PostgreSQL result identifier
$arr   &$arr     (reference) array where data from the row is stored
$fetchmode   $fetchmode     how the array data should be indexed
$rownum   $rownum     the row number to fetch

[ Top ]

fetchRow   [line 415]

array fetchRow( $result $result, [$fetchmode $fetchmode = DB_FETCHMODE_DEFAULT], [$rownum $rownum = null])

Fetch and return a row of data (it uses fetchInto for that)
  • Return: a row of data, or false on error

Parameters:

$result   $result     LDAP result identifier
$fetchmode   $fetchmode     format of fetched row array
$rownum   $rownum     the absolute row number to fetch

[ Top ]

freeResult   [line 542]

bool freeResult( $result $result)

Free the internal resources associated with $result.
  • Return: TRUE on success, FALSE if $result is invalid

Parameters:

$result   $result     int LDAP result identifier or DB statement identifier

[ Top ]

getListOf   [line 663]

int getListOf( mixed $type)

Returns the query needed to get some backend info. This function is used only for compatibility reasons.
  • Return: DB_ERROR_NOT_CAPABLE error code

[ Top ]

getTables   [line 649]

void getTables( )

  • Deprecated:

[ Top ]

isManip   [line 679]

boolean isManip( string $action)

Tell whether an action is a data manipulation action (add, compare, delete, modify, mod_add, mod_del, mod_replace, rename)
  • Return: whether $query is a data manipulation action

Parameters:

string   $action     the query

[ Top ]

ldapExplodeDN   [line 1235]

array ldapExplodeDN( string $dn, [int $with_attrib = 0])

Splits the DN and breaks it up into its component parts.

Each part is known as Relative Distinguished Name, or RDN.

  • Return: an array of all those components

Parameters:

string   $dn     the DN to split
int   $with_attrib     0 to get RDNs with the attributes or 1 to get only values.

[ Top ]

ldapGetOption   [line 1214]

bool ldapGetOption( int $option, mixed &$retval)

Gets the current value for given option.

Parameters:

int   $option     the specified option
mixed   $retval     (reference) the new value of specified option

[ Top ]

ldapGetParam   [line 1172]

mixed ldapGetParam( string $param)

Gets the default parameters for query.

Parameters:

string   $param     the name of parameter for search or modify actions.

[ Top ]

ldapRaiseError   [line 865]

mixed ldapRaiseError( [int $errno = null])

Generate error message for LDAP errors.
  • Return: DB_OK on success or DB error on error

Parameters:

int   $errno     error number

[ Top ]

ldapSetAction   [line 715]

void ldapSetAction( [mixed $action = 'search'])

  • Deprecated:

[ Top ]

ldapSetBaseDN   [line 702]

void ldapSetBaseDN( [mixed $base_dn = null])

  • Deprecated:

[ Top ]

ldapSetOption   [line 1193]

bool ldapSetOption( int $option, mixed $newval)

Sets the value of the given option.

Parameters:

int   $option     the specified option
mixed   $newval     the value of specified option

[ Top ]

ldapSetParam   [line 1150]

mixed ldapSetParam( string $param, string $value)

Sets the default parameters for query.

Parameters:

string   $param     the name of parameter for search actions (action, base_dn, attributes, attrsonly, sizelimit, timelimit, deref) or modify actions (action, attribute, value, newrdn, newparent, deleteoldrdn).
string   $value     the value of parameter

[ Top ]

nextId   [line 737]

a nextId( string $seq_name, [bool $ondemand = true])

Get the next value in a sequence.

LDAP provides transactions for only one entry and we need to prevent race condition. If unique value before and after modify aren't equal then wait and try again.

  • Return: sequence integer, or a DB error

Parameters:

string   $seq_name     the sequence name
bool   $ondemand     whether to create the sequence on demand

[ Top ]

nextResult   [line 399]

true nextResult( a $result)

Move the internal ldap result pointer to the next available result
  • Return: if a result is available otherwise return false
  • Access: public

Parameters:

a   $result     valid ldap result resource

[ Top ]

numCols   [line 591]

int numCols( $result $result)

Get the number of columns in a result set. This function is used only for compatibility reasons.
  • Return: DB_ERROR_NOT_CAPABLE error code

Parameters:

$result   $result     resource LDAP result identifier

[ Top ]

numRows   [line 606]

int numRows( $result $result)

Get the number of rows in a result set.
  • Return: the number of rows in $result

Parameters:

$result   $result     resource LDAP result identifier

[ Top ]

prepare   [line 930]

resource prepare( mixed $query)

Prepares a query for multiple execution with execute().

This behaviour is emulated for LDAP backend. prepare() requires a generic query as an array with special characters (wildcards) as values.

Types of wildcards: ? - a quoted scalar value, i.e. strings, integers & - requires a file name, the content of the file insert into the query (i.e. saving binary data in a db) ! - value is inserted 'as is'

Example:

$sth = $dbh->prepare( array( array( 'dn' => '?', 'objectClass' => '?', 'cn' => '?', 'sn' => '?', 'description' => '&' ), 'action' => 'add' ); );

$sigfile = "/home/dexter/.signature"; $res = $dbh->execute($sth, array( 'cn=Piotr Roszatycki,dc=example,dc=com', array('top', 'person'), 'Piotr Roszatycki', 'Roszatycki', $sigfile ));

  • Return: handle for the query
  • See: execute

Parameters:

mixed   $query     the query to prepare

[ Top ]

quote   [line 574]

mixed quote( [$string $str = null])

Quote the given string so it can be safely used within string delimiters in a query.
  • Return: "NULL" string, quoted string or original data

Parameters:

$string   $str     mixed Data to be quoted

[ Top ]

simpleQuery   [line 293]

int simpleQuery( mixed $query)

Performs a request against the LDAP server

The type of request depend on $query parameter. If $query is string, perform simple searching query with filter in $query parameter. If $query is array, the first element of array is filter string (for reading operations) or data array (for writing operations). Another elements of $query array are query parameters which overrides the default parameters.

The following parameters can be passed for search queries:
<li />base_dn <li />attributes - array, the attributes that shall be returned <li />attrsonly <li />sizelimit - integer, the max number of results to be returned <li />timelimit - integer, the timelimit after which to stop searching <li />deref - <li/>sort - string, which tells the attribute name by which to sort

I.e.:

  • Return: result from LDAP function for failure queries, DB_OK for successful queries or DB Error object if wrong syntax

Parameters:

mixed   $query     the ldap query

[ Top ]


Documentation generated on Sat, 1 May 2004 00:39:53 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.