Methods summary
public
|
#
__construct( array $config = array() )
Constructor.
Parameters
- $config
- Configuration array.
See
$_config
|
public
|
|
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
|
public
|
#
disconnect( )
Closes the LDAP connection.
Closes the LDAP connection.
|
public
|
#
startTLS( )
Starts an encrypted session.
Starts an encrypted session.
Throws
|
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
Throws
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
|
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
See
|
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
Throws
|
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
Returns
string The user's full DN.
Throws
|
public
|
#
setOption( string $option, mixed $value )
Sets an LDAP option.
Parameters
- $option
- Option to set.
- $value
- Value to set option to.
Throws
|
public
Horde_Ldap_Error|string
|
#
getOption( string $option )
Returns an LDAP option value.
Returns an LDAP option value.
Parameters
Returns
Horde_Ldap_Error|string Horde_Ldap_Error or option value
Throws
|
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
|
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
|
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
Throws
|
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
|
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
Throws
|
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
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
Throws
|
public
Horde_Ldap_Schema
|
#
schema( string $dn = null )
Returns a schema object
Parameters
Returns
Throws
|
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
|
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
|
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> => <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> => <span class="php-keyword1">array</span>(<span class="php-quote">'dc'</span>, <span class="php-quote">'example'</span>),
<span class="php-num">2</span> => <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.
|