__construct (Constructor) [line 149]
add [line 556]
Adds a new attribute or a new value to an existing attribute
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, else 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.
Note, that you can add values of attributes that you haven't selected, but if you do so, getValue() and getValues() will only return the values you added, _NOT_ all values present on the server. To avoid this, just refetch the entry after calling update() or select the attribute.
Parameters:
attributes [line 517]
Returns an array of attributes names
createConnected [line 233]
Creates a Net_LDAP2_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.
Please note, that if you want to create an entry object that represents some already existing entry, you should use createExisting().
The method should be called statically: $entry = Net_LDAP2_Entry::createConnected();
Parameters:
createExisting [line 276]
Creates an Net_LDAP2_Entry object that is considered already existing
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 Net_LDAP2->getEntry()!
Please note that 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.
This method is equal to calling createFresh() and after that markAsNew(FALSE).
The method should be called statically: $entry = Net_LDAP2_Entry::createExisting();
The attributes parameter is as following: $attrs = array( 'attribute1' => array('value1', 'value2'),
'attribute2' => 'single value'
);
Parameters:
createFresh [line 206]
Creates a fresh entry that may be added to the directory later on
Use this method, if you want to initialize a fresh entry.
The method should be called statically: $entry = Net_LDAP2_Entry::createFresh(); 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:
currentDN [line 1081]
Returns always the original DN
If an entry will be moved but update() was not called, dn() will return the new DN. This method however, returns always the current active DN.
delete [line 617]
true delete(
[string|array
$attr = null])
|
|
Deletes an whole attribute or 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 given attributes will be deleted array("attributename" => "value") - The value will be deleted array("attributename" => array("value1", "value2") - The given values will be deleted If $attr is null or omitted , then the whole Entry will be deleted!
These changes are local to the entry and do not affect the entry on the server until update() is called.
Please note that you must select the attribute (at $ldap->search() for example) to be able to delete values of it, Otherwise update() will silently fail and remove nothing.
Parameters:
dn [line 309]
string|true dn(
[string
$dn = null])
|
|
Get or set 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 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 currentDN() to retrieve the DN that is currently active.
Please note that special characters (eg german umlauts) should be encoded using utf8_encode(). You may use Net_LDAP2_Util::canonical_dn() for properly encoding of the DN.
Parameters:
exists [line 530]
boolean exists(
string
$attr)
|
|
Returns whether an attribute exists or not
Parameters:
getAttrName [line 902]
string getAttrName(
string
$attr)
|
|
Returns the right attribute name
Parameters:
getChanges [line 1091]
Returns the attribute changes to be carried out once update() is called
getLDAP [line 917]
Returns a reference to the LDAP-Object of this entry
getValue [line 460]
string|array getValue(
string
$attr, [string
$option = null])
|
|
Get 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 'default': 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
If the attribute is not set at this entry (no value or not defined in schema), "false" is returned when $option is 'single', an empty string if 'default', and an empty array when 'all'.
You may use Net_LDAP2_Schema->checkAttribute() to see if the attribute is defined for the objectClasses of this entry.
Parameters:
getValues [line 427]
Get the values of all attributes in a hash
The returned hash has the form array('attributename' => 'single value',
'attributename' => array('value1', value2', value3'))
Only attributes present at the entry will be returned.
get_value [line 505]
string|array|PEAR_Error get_value(
)
|
|
Alias function of getValue for perl-ldap interface
isNew [line 1046]
Tells if the entry is consiedered as new (not present in the server)
Please note, that this doesn't tell you if the entry is present on the server. Use Net_LDAP2::dnExists() to see if an entry is already there.
markAsNew [line 961]
void markAsNew(
[boolean
$mark = true])
|
|
Marks the entry as new/existing.
If an Entry is marked as new, it will be added to the directory when calling 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 update().
Parameters:
move [line 332]
true move(
string
$newdn)
|
|
Renames or moves the entry
This is just a convinience alias to dn() to make your code more meaningful.
Parameters:
pregMatch [line 1007]
boolean|Net_LDAP2_Error pregMatch(
string
$regex, string
$attr_name, [array
$matches = array()])
|
|
Applies a regular expression onto a single- or multivalued attribute (like preg_match())
This method behaves like PHPs preg_match() but with some exceptions. If you want to retrieve match information, then you MUST pass the $matches parameter via reference! otherwise you will get no matches. Since it is possible to have multi valued attributes the $matches array will have a additionally numerical dimension (one for each value): $matches = array(
)
Please note, that $matches will be initialized to an empty array inside.
Usage example: $result =
$entry->preg_match('/089(\d+)/', 'telephoneNumber', $matches);
if ( $result === true ){
echo "First match: ".$matches[0][1]; // Match of value 1, content of first bracket
} else {
echo "Error: ".$result->getMessage();
} else {
echo "No match found.";
}
}
Please note that it is important to test for an Net_LDAP2_Error, because objects are evaluating to true by default, thus if an error occured, and you only check using "==" then you get misleading results. Use the "identical" (===) operator to test for matches to avoid this as shown above.
Parameters:
preg_match [line 1032]
Alias of pregMatch() for compatibility to Net_LDAP 1
replace [line 706]
true|Net_LDAP2_Error replace(
[array
$attr = array()], [bool
$force = false])
|
|
Replaces attributes or its 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 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:
setAttributes [line 352]
void setAttributes(
[array
$attributes = null])
|
|
Sets the internal attributes array
This fetches the values for the attributes from the server. The attribute Syntax will be checked so binary attributes will be returned as binary values.
Attributes may be passed directly via the $attributes parameter to setup this entry manually. This overrides attribute fetching from the server.
Parameters:
setLDAP [line 938]
Sets a reference to the LDAP-Object of this entry
After setting a Net_LDAP2 object, calling update() will use that object for updating directory contents. Use this to dynamicly switch directorys.
Parameters:
update [line 754]
Update the entry on the directory server
This will evaluate all changes made so far and send them to the directory server. Please note, that 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.
Parameters:
willBeDeleted [line 1057]
Is this entry going to be deleted once update() is called?
willBeMoved [line 1067]
Is this entry going to be moved once update() is called?