Methods summary
public static
Horde_Ldap_Entry
|
#
createFresh( string $dn, array $attrs = array() )
Creates a fresh entry that may be added to the directory later.
Creates a fresh entry that may be added to the directory later.
You should put a 'objectClass' attribute into the $attrs so the
directory server knows which object you want to create. However, you may
omit this in case you don't want to add this entry to a directory
server.
The attributes parameter is as following:
$attrs = array('attribute1' => array('value1', 'value2'),
'attribute2' => 'single value');
Parameters
- $dn
- DN of the entry.
- $attrs
- Attributes of the entry.
Returns
Throws
|
public static
Horde_Ldap_Entry
|
#
createConnected( Horde_Ldap $ldap, resource $entry )
Creates an entry object out of an LDAP entry resource.
Creates an entry object out of an LDAP entry resource.
Use this method, if you want to initialize an entry object that is
already present in some directory and that you have read manually.
Parameters
- $ldap
- Horde_Ldap object.
- $entry
- PHP LDAP entry resource.
Returns
Throws
|
public static
Horde_Ldap_Entry
|
#
createExisting( string $dn, array $attrs = array() )
Creates an entry object that is considered to exist already.
Creates an entry object that is considered to exist already.
Use this method, if you want to modify an already existing entry without
fetching it first. In most cases however, it is better to fetch the
entry via Horde_Ldap::getEntry().
You should take care if you construct entries manually with this because
you may get weird synchronisation problems. The attributes and values
as well as the entry itself are considered existent which may produce
errors if you try to modify an entry which doesn't really exist or if
you try to overwrite some attribute with an value already present.
The attributes parameter is as following:
$attrs = array('attribute1' => array('value1', 'value2'),
'attribute2' => 'single value');
Parameters
- $dn
- DN of the entry.
- $attrs
- Attributes of the entry.
Returns
Throws
|
public
string
|
#
dn( string $dn = null )
Returns or sets the distinguished name of the entry.
Returns or sets the distinguished name of the entry.
If called without an argument the current (or the new DN if set) DN gets
returned.
If you provide an DN, this entry is moved to the new location specified
if a DN existed.
If the DN was not set, the DN gets initialized. Call Horde_Ldap_Entry::update() to
actually create the new entry in the directory.
To fetch the current active DN after setting a new DN but before an
update(), you can use Horde_Ldap_Entry::currentDN() to retrieve the DN that is
currently active.
Parameters
- $dn
- New distinguished name.
Returns
string Distinguished name.
|
public
array
|
#
getValues( )
Returns the values of all attributes in a hash.
Returns the values of all attributes in a hash.
The returned hash has the form
array('attributename' => 'single value',
'attributename' => array('value1', value2', value3'))
Returns
array Hash of all attributes with their values.
Throws
|
public
string|array
|
#
getValue( string $attr, string $option = null )
Returns the value of a specific attribute.
Returns the value of a specific attribute.
The first parameter is the name of the attribute.
The second parameter influences the way the value is returned:
- 'single': only the first value is returned as string.
- 'all': all values are returned in an array.
In all other cases an attribute value with a single value is returned as
string, if it has multiple values it is returned as an array.
Parameters
- $attr
- Attribute name.
- $option
- Option.
Returns
string|array Attribute value(s).
Throws
|
public
array
|
#
attributes( )
Returns an array of attributes names.
Returns an array of attributes names.
Returns
array Array of attribute names.
|
public
boolean
|
#
exists( string $attr )
Returns whether an attribute exists or not.
Returns whether an attribute exists or not.
Parameters
Returns
boolean True if the attribute exists.
|
public
|
#
add( array $attr = array() )
Adds new attributes or a new values to existing attributes.
Adds new attributes or a new values to existing attributes.
The paramter has to be an array of the form:
array('attributename' => 'single value',
'attributename' => array('value1', 'value2'))
When the attribute already exists the values will be added, otherwise
the attribute will be created. These changes are local to the entry and
do not affect the entry on the server until update() is called.
You can add values of attributes that you haven't originally selected,
but if you do so, Horde_Ldap_Entry::getValue() and Horde_Ldap_Entry::getValues() will only
return the values you added, NOT all values present on the server. To
avoid this, just refetch the entry after calling Horde_Ldap_Entry::update() or
select the attribute.
Parameters
|
public
|
#
delete( string|array $attr = null )
Deletes an attribute, a value or the whole entry.
Deletes an attribute, a value or the whole entry.
The parameter can be one of the following:
- 'attributename': the attribute as a whole will be deleted.
- array('attributename1', 'attributename2'): all specified attributes will be deleted.
- array('attributename' => 'value'): the specified attribute value will be deleted.
- array('attributename' => array('value1', 'value2'): The specified attribute values will be deleted.
- null: the whole entry will be deleted.
These changes are local to the entry and do not affect the entry on the
server until Horde_Ldap_Entry::update() is called.
You must select the attribute (at $ldap->search() for example) to be
able to delete values of it, Otherwise Horde_Ldap_Entry::update() will silently
fail and remove nothing.
Parameters
- $attr
- Attributes to delete.
|
public
|
#
replace( array $attr = array(), boolean $force = false )
Replaces attributes or their values.
Replaces attributes or their values.
The parameter has to an array of the following form:
array('attributename' => 'single value',
'attribute2name' => array('value1', 'value2'),
'deleteme1' => null,
'deleteme2' => '')
If the attribute does not yet exist it will be added instead (see also
$force). If the attribue value is null, the attribute will de deleted.
These changes are local to the entry and do not affect the entry on the
server until Horde_Ldap_Entry::update() is called.
In some cases you are not allowed to read the attributes value (for
example the ActiveDirectory attribute unicodePwd) but are allowed to
replace the value. In this case replace() would assume that the
attribute is not in the directory yet and tries to add it which will
result in an LDAP_TYPE_OR_VALUE_EXISTS error. To force replace mode
instead of add, you can set $force to true.
Parameters
- $attr
- Attributes to replace.
- $force
- <p>Force replacing mode in case we can't read the
attribute value but are allowed to replace it.</p>
|
public
|
#
update( )
Updates the entry on the directory server.
Updates the entry on the directory server.
This will evaluate all changes made so far and send them to the
directory server.
If you make changes to objectclasses wich have mandatory attributes set,
update() will currently fail. Remove the entry from the server and readd
it as new in such cases. This also will deal with problems with setting
structural object classes.
Throws
|
public
Horde_Ldap
|
#
getLDAP( )
Returns a reference to the LDAP-Object of this entry.
Returns a reference to the LDAP-Object of this entry.
Returns
Horde_Ldap
Reference to the Horde_Ldap object (the connection).
Throws
|
public
|
#
setLDAP( Horde_Ldap $ldap )
Sets a reference to the LDAP object of this entry.
Sets a reference to the LDAP object of this entry.
After setting a Horde_Ldap object, calling update() will use that object
for updating directory contents. Use this to dynamicly switch
directories.
Parameters
- $ldap
- <p>Horde_Ldap object that this entry should be
connected to.</p>
Throws
|
public
|
#
markAsNew( boolean $mark = true )
Marks the entry as new or existing.
Marks the entry as new or existing.
If an entry is marked as new, it will be added to the directory when
calling Horde_Ldap_Entry::update() .
If the entry is marked as old ($mark = false), then the entry is assumed
to be present in the directory server wich results in modification when
calling Horde_Ldap_Entry::update() .
Parameters
- $mark
- Whether to mark the entry as new.
|
public
boolean
|
#
pregMatch( string $regex, string $attr_name, array & $matches = array() )
Applies a regular expression onto a single- or multi-valued attribute
(like preg_match()).
Applies a regular expression onto a single- or multi-valued attribute
(like preg_match()).
This method behaves like PHP's preg_match() but with some exception.
Since it is possible to have multi valued attributes the $matches
array will have a additionally numerical dimension (one for each value):
$matches = array(
0 => array (usual preg_match() returned array),
1 => array (usual preg_match() returned array)
)
$matches will always be initialized to an empty array inside.
Usage example:
try {
if ($entry->pregMatch('/089(\d+)/', 'telephoneNumber', $matches)) {
echo 'First match: ' . $matches[0][1];
} else {
echo 'No match found.';
}
} catch (Horde_Ldap_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Parameters
- $regex
- The regular expression.
- $attr_name
- The attribute to search in.
- $matches
- Array to store matches in.
Returns
boolean True if we had a match in one of the values.
Throws
|
public
boolean
|
#
isNew( )
Returns whether the entry is considered new (not present in the server).
Returns whether the entry is considered new (not present in the server).
This method doesn't tell you if the entry is really not present on the
server. Use Horde_Ldap::exists() to see if an entry is already
there.
Returns
boolean True if this is considered a new entry.
|
public
boolean
|
#
willBeDeleted( )
Is this entry going to be deleted once update() is called?
Is this entry going to be deleted once update() is called?
Returns
boolean True if this entry is going to be deleted.
|
public
boolean
|
#
willBeMoved( )
Is this entry going to be moved once update() is called?
Is this entry going to be moved once update() is called?
Returns
boolean True if this entry is going to be move.
|
public
string
|
|
public
array
|
#
getChanges( )
Returns the attribute changes to be carried out once update() is called.
Returns the attribute changes to be carried out once update() is called.
Returns
array The due changes.
|