Overview

Packages

  • Ldap

Classes

  • Horde_Ldap
  • Horde_Ldap_Entry
  • Horde_Ldap_Exception
  • Horde_Ldap_Filter
  • Horde_Ldap_Ldif
  • Horde_Ldap_RootDse
  • Horde_Ldap_Schema
  • Horde_Ldap_Search
  • Horde_Ldap_Util
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Ldap

The main Horde_Ldap class.

Copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger Copyright 2009-2012 Horde LLC (http://www.horde.org/)

Package: Ldap
License: LGPLv3
Author: Tarjej Huse tarjei@bergfald.no
Author: Jan Wagner wagner@netsols.de
Author: Del del@babel.com.au
Author: Benedikt Hallinger beni@php.net
Author: Ben Klang ben@alkaloid.net
Author: Chuck Hagenbuch chuck@horde.org
Author: Jan Schneider jan@horde.org
Located at Horde/Ldap.php
Methods summary
public
# __construct( array $config = array() )

Constructor.

Constructor.

Parameters

$config
Configuration array.

See

$_config
public
# __destruct( )

Destructor.

Destructor.

public
# bind( string $dn = null, string $password = null )

Bind or rebind to the LDAP server.

Bind or rebind to the LDAP server.

This function binds with the given DN and password to the server. In case no connection has been made yet, it will be started and STARTTLS issued if appropiate.

The internal bind configuration is not being updated, so if you call bind() without parameters, you can rebind with the credentials provided at first connecting to the server.

Parameters

$dn
DN for binding.
$password
Password for binding.

Throws

Horde_Ldap_Exception
public
# disconnect( )

Closes the LDAP connection.

Closes the LDAP connection.

public
# startTLS( )

Starts an encrypted session.

Starts an encrypted session.

Throws

Horde_Ldap_Exception
public
# add( Horde_Ldap_Entry $entry )

Adds a new entry to the directory.

Adds a new entry to the directory.

This also links the entry to the connection used for the add, if it was a fresh entry.

Parameters

$entry
An LDAP entry.

Throws

Horde_Ldap_Exception

See

HordeLdap_Entry::createFresh()
public
# delete( string|Horde_Ldap_Entry $dn, boolean $recursive = false )

Deletes an entry from the directory.

Deletes an entry from the directory.

Parameters

$dn
DN string or Horde_Ldap_Entry.
$recursive
<p>Should we delete all children recursivelx as well?</p>

Throws

Horde_Ldap_Exception
public
# modify( string|Horde_Ldap_Entry $entry, array $parms = array() )

Modifies an LDAP entry on the server.

Modifies an LDAP entry on the server.

The $params argument is an array of actions and should be something like this:

array('add' => array('attribute1' => array('val1', 'val2'),
                     'attribute2' => array('val1')),
      'delete' => array('attribute1'),
      'replace' => array('attribute1' => array('val1')),
      'changes' => array('add' => ...,
                         'replace' => ...,
                         'delete' => array('attribute1', 'attribute2' => array('val1')))

The order of execution is as following: 1. adds from 'add' array 2. deletes from 'delete' array 3. replaces from 'replace' array 4. changes (add, replace, delete) in order of appearance

The function calls the corresponding functions of an Horde_Ldap_Entry object. A detailed description of array structures can be found there.

Unlike the modification methods provided by the Horde_Ldap_Entry object, this method will instantly carry out an update() after each operation, thus modifying "directly" on the server.

Parameters

$entry
DN string or Horde_Ldap_Entry.
$parms
Array of changes

Throws

Horde_Ldap_Exception

See

Horde_Ldap_Entry::add()
Horde_Ldap_Entry::delete()
Horde_Ldap_Entry::replace()
public Horde_Ldap_Search
# search( string|Horde_Ldap_Entry $base = null, string|Horde_Ldap_Filter $filter = null, array $params = array() )

Runs an LDAP search query.

Runs an LDAP search query.

$base and $filter may be ommitted. The one from config will then be used. $base is either a DN-string or an Horde_Ldap_Entry object in which case its DN will be used.

$params may contain: - scope: The scope which will be used for searching, defaults to 'sub': - base: Just one entry - sub: The whole tree - one: Immediately below $base - sizelimit: Limit the number of entries returned (default: 0 = unlimited) - timelimit: Limit the time spent for searching (default: 0 = unlimited) - attrsonly: If true, the search will only return the attribute names - attributes: Array of attribute names, which the entry should contain. It is good practice to limit this to just the ones you need.

You cannot override server side limitations to sizelimit and timelimit: You can always only lower a given limit.

Parameters

$base
LDAP searchbase.
$filter
LDAP search filter.
$params
Array of options.

Returns

Horde_Ldap_Search
The search result.

Throws

Horde_Ldap_Exception
public string
# findUserDN( string $user )

Returns the DN of a user.

Returns the DN of a user.

The purpose is to quickly find the full DN of a user so it can be used to re-bind as this user. This method requires the 'user' configuration parameter to be set.

Parameters

$user
The user to find.

Returns

string
The user's full DN.

Throws

Horde_Ldap_Exception
Horde_Exception_NotFound
public
# setOption( string $option, mixed $value )

Sets an LDAP option.

Sets an LDAP option.

Parameters

$option
Option to set.
$value
Value to set option to.

Throws

Horde_Ldap_Exception
public Horde_Ldap_Error|string
# getOption( string $option )

Returns an LDAP option value.

Returns an LDAP option value.

Parameters

$option
Option to get.

Returns

Horde_Ldap_Error|string
Horde_Ldap_Error or option value

Throws

Horde_Ldap_Exception
public integer
# getVersion( )

Returns the LDAP protocol version that is used on the connection.

Returns the LDAP protocol version that is used on the connection.

A lot of LDAP functionality is defined by what protocol version the LDAP server speaks. This might be 2 or 3.

Returns

integer
The protocol version.
public
# setVersion( integer $version = 0, boolean $force = false )

Sets the LDAP protocol version that is used on the connection.

Sets the LDAP protocol version that is used on the connection.

Parameters

$version
LDAP version that should be used.
$force
<p>If set to true, the check against the rootDSE will be skipped.</p>

Throws

Horde_Ldap_Exception
public boolean
# exists( string|Horde_Ldap_Entry $dn )

Returns whether a DN exists in the directory.

Returns whether a DN exists in the directory.

Parameters

$dn
The DN of the object to test.

Returns

boolean
True if the DN exists.

Throws

Horde_Ldap_Exception
public Horde_Ldap_Entry
# getEntry( string $dn, array $attributes = array() )

Returns a specific entry based on the DN.

Returns a specific entry based on the DN.

Parameters

$dn
DN of the entry that should be fetched.
$attributes
<p>Array of Attributes to select. If ommitted, all attributes are fetched.</p>

Returns

Horde_Ldap_Entry
A Horde_Ldap_Entry object.

Throws

Horde_Ldap_Exception
Horde_Exception_NotFound
public
# move( string|Horde_Ldap_Entry $entry, string $newdn, Horde_Ldap $target_ldap = null )

Renames or moves an entry.

Renames or moves an entry.

This method will instantly carry out an update() after the move, so the entry is moved instantly.

You can pass an optional Horde_Ldap object. In this case, a cross directory move will be performed which deletes the entry in the source (THIS) directory and adds it in the directory $target_ldap.

A cross directory move will switch the entry's internal LDAP reference so updates to the entry will go to the new directory.

If you want to do a cross directory move, you need to pass an Horde_Ldap_Entry object, otherwise the attributes will be empty.

Parameters

$entry
An LDAP entry.
$newdn
The new location.
$target_ldap
<p>Target directory for cross server move.</p>

Throws

Horde_Ldap_Exception
public Horde_Ldap_Entry
# copy( Horde_Ldap_Entry $entry, string $newdn )

Copies an entry to a new location.

Copies an entry to a new location.

The entry will be immediately copied. Only attributes you have selected will be copied.

Parameters

$entry
An LDAP entry.
$newdn
New FQF-DN of the entry.

Returns

Horde_Ldap_Entry
The copied entry.

Throws

Horde_Ldap_Exception
public static string
# errorName( integer $errorcode )

Returns the string for an LDAP errorcode.

Returns the string for an LDAP errorcode.

Made to be able to make better errorhandling. Function based on DB::errorMessage().

Hint: The best description of the errorcodes is found here: http://www.directory-info.com/Ldap/LDAPErrorCodes.html

Parameters

$errorcode
An error code.

Returns

string
The description for the error.
public Horde_Ldap_RootDse
# rootDSE( array $attrs = array() )

Returns a rootDSE object

Returns a rootDSE object

This either fetches a fresh rootDSE object or returns it from the internal cache for performance reasons, if possible.

Parameters

$attrs
Array of attributes to search for.

Returns

Horde_Ldap_RootDse
Horde_Ldap_RootDse object

Throws

Horde_Ldap_Exception
public Horde_Ldap_Schema
# schema( string $dn = null )

Returns a schema object

Returns a schema object

Parameters

$dn
Subschema entry dn.

Returns

Horde_Ldap_Schema
Horde_Ldap_Schema object

Throws

Horde_Ldap_Exception
public static
# checkLDAPExtension( )

Checks if PHP's LDAP extension is loaded.

Checks if PHP's LDAP extension is loaded.

If it is not loaded, it tries to load it manually using PHP's dl(). It knows both windows-dll and *nix-so.

Throws

Horde_Ldap_Exception
public array|Horde_Ldap_Error
# utf8Encode( array $attributes )

Parameters

$attributes
An array of attributes.

Returns

array|Horde_Ldap_Error
An array of UTF8 encoded attributes or an error.
public array|Horde_Ldap_Error
# utf8Decode( array $attributes )

Parameters

$attributes
Array of attributes

Returns

array|Horde_Ldap_Error
Array with decoded attribute values or Error

See

Horde_Ldap::utf8Encode()
public resource
# getLink( )

Returns the LDAP link resource.

Returns the LDAP link resource.

It will loop attempting to re-establish the connection if the connection attempt fails and auto_reconnect has been turned on (see the _config array documentation).

Returns

resource
LDAP link.
public static string
# buildClause( string $lhs, string $op, string $rhs, array $params = array() )

Builds an LDAP search filter fragment.

Builds an LDAP search filter fragment.

Parameters

$lhs
The attribute to test.
$op
The operator.
$rhs
The comparison value.
$params
Any additional parameters for the operator.

Returns

string
The LDAP search fragment.
public static string
# quote( string $clause )

Escapes characters with special meaning in LDAP searches.

Escapes characters with special meaning in LDAP searches.

Parameters

$clause
The string to escape.

Returns

string
The escaped string.
public static string
# quoteDN( array $parts )

Takes an array of DN elements and properly quotes it according to RFC 1485.

Takes an array of DN elements and properly quotes it according to RFC 1485.

Parameters

$parts
<p>An array of tuples containing the attribute name and that attribute's value which make up the DN. Example:</p> <pre><span class="php-var">$parts</span> = <span class="php-keyword1">array</span>(<span class="php-num">0</span> =&gt; <span class="php-keyword1">array</span>(<span class="php-quote">'cn'</span>, <span class="php-quote">'John Smith'</span>), <span class="php-num">1</span> =&gt; <span class="php-keyword1">array</span>(<span class="php-quote">'dc'</span>, <span class="php-quote">'example'</span>), <span class="php-num">2</span> =&gt; <span class="php-keyword1">array</span>(<span class="php-quote">'dc'</span>, <span class="php-quote">'com'</span>));</pre>

Returns

string
The properly quoted string DN.
API documentation generated by ApiGen