note 748 modified in function.ldap-modify by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 02:18:51 +0000 |
| Subject: | note 748 modified in function.ldap-modify by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142455@lists.php.net to get a copy of this message | ||
Modifying existing LDAP information using ldap_modify()
The link_identifier must result from a call to connect to the server with authority to update
entries, usually requiring an authenticated bind - ie you provide a suitable dn and password in the
ldap_bind() call.
The dn must be a single specific dn that exists on the LDAP server. There is no wildcard
mechanism in LDAP to globally change multiple dn entries.
The entry array must be in one of two different forms, according to whether just one entry is to be
stored in the directory for a particular attribute, or whether multiple entries are to be stored for
the attribute.
Where a single entry is to be stored for an attribute - say just a single email address - then you
use the general form
$newinfo[ <attribute_name> ]="whatever" ;
for example ...
$newinfo["mail"]="john@myorg.com" ;
Where multiple entries are to be stored for an attribute - say a number of email addresses for one
person - then you use the general form
$newinfo[ <attribute_name> ][0] = "whatever" ;
$newinfo[ <attribute_name> ][1] = "another" ;
for example ...
$newinfo["mail"][0]="johnw@myorg.com" ;
$newinfo["mail"][1]="jwaterson@somewhere.org" ;
Further notes on ldap_modify()
The modify call leaves entries for all other attributes unaltered. So if you just want to update
the entry for the "mail" attribute, then all that is required is:
$newinfo[mail]="nick@county.gov.uk";
ldap_modify($valid_ldaplink, $valid_dn, $newinfo);
However, if there were multiple entries for the mail attribute present on the LDAP database when you
run the above code, then all the existing mail entries would be deleted and be replaced by the
single "mail" entry.
If you have reason to expect multiple values for a particular attribute (more that one email entry,
for example) you should make sure you read all the entries from the ldap server first, and then save
a modified array.
The PHP LDAP interface does not currently support direct modification of the dn. If the dn needs
changing, the only option is to read all entries for the dn and save these to a new, modified, dn
before deleting the complete entry for the original dn.
--was--
Modifying existing LDAP information using ldap_modify()
The link_identifier must result from a call to connect to the server with authority to update
entries, usually requiring an authenticated bind - ie you provide a suitable dn and password in the
ldap_bind() call.
<p>
The dn must be a single specific dn that exists on the LDAP server. There is no wildcard
mechanism in LDAP to globally change multiple dn entries.
<p>
The entry array must be in one of two different forms, according to whether just one entry is to be
stored in the directory for a particular attribute, or whether multiple entries are to be stored for
the attribute.
<p>
Where a single entry is to be stored for an attribute - say just a single email address - then you
use the general form
$newinfo[ <attribute_name> ]="whatever" ;
for example ...
$newinfo["mail"]="john@myorg.com" ;
Where multiple entries are to be stored for an attribute - say a number of email addresses for one
person - then you use the general form
$newinfo[ <attribute_name> ][0] = "whatever" ;
$newinfo[ <attribute_name> ][1] = "another" ;
for example ...
$newinfo["mail"][0]="johnw@myorg.com" ;
$newinfo["mail"][1]="jwaterson@somewhere.org" ;
Further notes on ldap_modify()
The modify call leaves entries for all other attributes unaltered. So if you just want to update
the entry for the "mail" attribute, then all that is required is:
$newinfo[mail]="nick@county.gov.uk";
ldap_modify($valid_ldaplink, $valid_dn, $newinfo);
However, if there were multiple entries for the mail attribute present on the LDAP database when you
run the above code, then all the existing mail entries would be deleted and be replaced by the
single "mail" entry.
<p>
If you have reason to expect multiple values for a particular attribute (more that one email entry,
for example) you should make sure you read all the entries from the ldap server first, and then save
a modified array.
<p>
The PHP LDAP interface does not currently support direct modification of the dn. If the dn needs
changing, the only option is to read all entries for the dn and save these to a new, modified, dn
before deleting the complete entry for the original dn.
http://php.net/manual/en/function.ldap-modify.php