ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:ldap

This is an old revision of the document!


LDAP

Specification
Driver Nameldap
Data Providerldap
StatusInactive1)
WindowsYes
UnixPerhaps2)
ADOdb V5Yes
ADOdb V6Yes

Description

The ldap driver provides a small subset of ADOdb commands allowing read-only access to an LDAP database.

Available Methods

The following methods are available for use with the LDAP driver:

Calls to other methods when used with this driver may produce unexpected results or program failure.

Usage

You must use the acceptable query terms for AD queries, rather than SQL statements. Any value added to bind parameter field is ignored

$db = newAdoConnection('ldap');
$baseDN   = 'dc=test,dc=loc';
$adServer = '192.168.1.16';
$user     = 'adodb@test.loc';
$password = 'adodb!';
 
$db->connect($adServer,$user,$password,$baseDN);
 
$result = $db->execute('(samaccountname=adodb)');

URI Connections

The Server definition can be set in the form ldap://server-name. You must use this if you want to:

  1. Use an alternate connection port ldap:⁄⁄server-name:3389
  2. Use ldap over SSL - ldaps:⁄⁄server-name

Connection Parameters

The following values may be injected into the connection via the use of setConnectionParameter()

OPTION_NAME Type
LDAP_OPT_DEREF integer
LDAP_OPT_SIZELIMIT integer
LDAP_OPT_TIMELIMIT integer
LDAP_OPT_PROTOCOL_VERSION integer
LDAP_OPT_ERROR_NUMBER integer
LDAP_OPT_REFERRALS boolean
LDAP_OPT_RESTART boolean
LDAP_OPT_HOST_NAME string
LDAP_OPT_ERROR_STRING string
LDAP_OPT_MATCHED_DN string
LDAP_OPT_SERVER_CONTROLS array
LDAP_OPT_CLIENT_CONTROLS array

From ADOdb 5.22.7, default values set are as follows

ParameterValue
LDAP_OPT_PROTOCOL_VERSION3
LDAP_OPT_REFERRALS0

These values can be changed with setConnectionParameter()

The following usage method is deprecated in PHP8.2 and will not work with PHP 8.3. Use setConnectionParameter() instead.

$LDAP_CONNECT_OPTIONS = Array(
	Array (
		"OPTION_NAME"=>LDAP_OPT_DEREF,
		"OPTION_VALUE"=>2
	),
	Array (
		"OPTION_NAME"=>LDAP_OPT_SIZELIMIT,
		"OPTION_VALUE"=>100
	),
	Array (
		"OPTION_NAME"=>LDAP_OPT_TIMELIMIT,
		"OPTION_VALUE"=>30
	),
	Array (
		"OPTION_NAME"=>,
		"OPTION_VALUE"=>3
	),
	Array (
		"OPTION_NAME"=>LDAP_OPT_ERROR_NUMBER,
		"OPTION_VALUE"=>13
	),
	Array (
		"OPTION_NAME"=>LDAP_OPT_REFERRALS,
		"OPTION_VALUE"=>FALSE
	),
	Array (
		"OPTION_NAME"=>LDAP_OPT_RESTART,
		"OPTION_VALUE"=>FALSE
	)
);
1)
This driver is not actively supported or enhanced by ADOdb project members, but you can provide fixes and enhancements if you have the expertise
2)
We have never tried it except against Microsoft LDAP servers from Windows
v5/database/ldap.1700235906.txt.gz · Last modified: 2023/11/17 16:45 by mnewnham