Class: LDAP
- Package: saf.Database
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 0.2, 2002-08-27, $Id: LDAP.php,v 1.6 2007/10/06 00:06:30 lux Exp $
- Access: public
A wrapper around the PHP LDAP extension.
Usage Example
<?php
$ldap = new LDAP ('server', 389, 'username', 'password');
if ($ldap->search ($dn, $filter)) {
while ($entry = $ldap->fetch ()) {
// do something with $entry
}
}
$ldap->free ();
$ldap->close ();
?>
Properties
$connection
- Access: public
The current connection resource.
$path
- Access: public
Path to the Berkeley Database.
$mode
- Access: public
Mode to use when opening the database (corresponds to
the modes available to the dba_open () function.
$handler
- Access: public
The database implementation used (db2, db3, gdbm, etc.).
$persistent
- Access: public
A 1 or 0 (true or false, and true by default), specifying whether
to establish a persistent connection or not.
$transactions = 0
- Access: public
Boolean value denoting whether to enable transactions in the
current database.
$driver
- Access: public
Contains the name of the database driver being used.
$host
- Access: public
Contains the name of the database host.
$name
- Access: public
Contains the name of the database being used.
$user
- Access: public
Contains the username used to connect to the current database.
$pass
- Access: public
Contains the password used to connect to the current database.
$dbd
- Access: private
Contains the loaded database driver.
$error
- Access: public
The message of the previous error.
$sql = ''
- Access: public
Contains the SQL query to be executed.
$rows
- Access: public
Contains the number of rows returned by the previous fetch() call.
$lastid
- Access: public
Contains the lastid() of the last insert query sent to the execute()
method.
$tables = false
- Access: public
Contains a list of tables in the database. Set by getTables().
$pearEmu = false
$sequenceFormat = '%s_seq'
$fetchMode = DB_FETCHMODE_OBJECT
$result = ''
- Access: public
Contains the result identifier for the current execution.
$field = ''
- Access: public
Currently unused.
$_fetchModeFunctions = array (
DB_FETCHMODE_ASSOC => 'mysql_fetch_array',
DB_FETCHMODE_OBJECT => 'mysql_fetch_object',
)
DB_FETCHMODE_ASSOC => 'mysql_fetch_array',
DB_FETCHMODE_OBJECT => 'mysql_fetch_object',
)
$typemap = array (
'bpchar' => 'text',
'char' => 'text',
'varchar' => 'text',
'text' => 'textarea',
'date' => 'date',
'time' => 'time',
'timestamp' => 'datetime',
'.*' => 'text',
// arrays
// booleans
// blobs
)
'bpchar' => 'text',
'char' => 'text',
'varchar' => 'text',
'text' => 'textarea',
'date' => 'date',
'time' => 'time',
'timestamp' => 'datetime',
'.*' => 'text',
// arrays
// booleans
// blobs
)
- Access: public
Contains a key/value list of database types (regular
expressions are used here to save repeating ourselves) and their
corresponding MailForm widget types.
$column
- Access: public
Column name of the facet.
$title
- Access: public
Dispaly name of the facet.
$extra
- Access: public
Extra info about the facet.
$tableObj
- Access: public
DatabaseTable object.
$items = array ()
- Access: public
List of options in the facet.
$type = 'normal'
- Access: public
Type of the facet. Possible values are 'normal', 'self_ref', 'date', and 'time'.
This value is auto-determined by compile(), but can be customized as well.
$table = ''
Table name.
$fields = array ()
List of all fields for this table.
$pkey = ''
Primary key field.
$fkey = ''
Optional name of a foreign key field, for use in simplified find() calls.
$listFields = '*'
The list of fields to return on find(). Default is '*' to return all fields.
$isAuto = true
Whether the pkey is auto-incrementing or not.
$orderBy = ''
Contains the "order by" clause value (ie. "name asc") for calls to find().
$groupBy = ''
Contains the "group by" clause value (ie. "name asc") for calls to find().
$limit = false
Contains the "limit" clause value for calls to find().
$offset = false
Contains the "offset" clause value for calls to find().
$invalid = array ()
A list of invalid fields and their corresponding error messages,
from the previous validate() call.
$usePermissions = false
Determines whether to automatically add access control to find(), count(),
and get() calls.
$multilingual = false
Enables automatic translation of items pulled from the database through
Sitellite's new multilingual capabilities.
$_cascade = array ()
This is the list of external types to cascade deletions across. In the
case of external objects, the keys are the object names and the values
are the referencing field in the external object's table. In the case
of join tables for many-to-many relationships, the keys are simply
numeric and the value is an array containing the join table name and the
name of the field referring to the current object's primary key field.
Ordinarily, these values are set automatically via the load() method,
and the relationships are defined in an INI file.
$server
- Access: public
The name of the server to connect to.
$port
- Access: public
The port to use to connect to the server.
$rdn
- Access: public
The rdn (username, essentially) to use to bind to
the connection.
$password
- Access: public
The password to use to bind to the connection.
$secure
- Access: public
Whether to use TLS for LDAP connections.
$resource
- Access: public
The current search resource.
$firstCalled
- Access: public
Says whether or not the first search result entry has
been returned.
$errno
- Access: public
The errno of the previous error.
Methods
LDAP ($server = 'localhost', $port = 389, $rdn = '', $password = '', $secure = false)
- Access: public
Constructor method. Connects to the server and binds
the username and password.
connect ($server, $port = 389, $secure = false)
- Access: public
- Return: boolean
Connects to the server.
bind ($rdn = '', $password = '')
- Access: public
- Return: boolean
Verifies the $rdn and $password.
search ($dn, $filter, $attrs = array (), $scope = 'sub')
- Access: public
- Return: boolean
Queries the database.
getEntries ()
- Access: public
- Return: associative array
Returns all of the results of the current search as
one big associative array of objects.
fetch ()
- Access: public
- Return: associative array
Fetches the next record in the search results as an
associative array. Returns false when there are no more results.
makeObj ($attrs)
- Access: public
- Return: object
Convert the returned attributes into the properties of an object.
free ()
- Access: public
- Return: boolean
Clears the current search result resource.
close ()
- Access: public
Closes the connection to the server.
