Consider an example:
$dn = "cn=John Wayne,ou=People,dc=OpenLDAP,dc=org";
$attrs = array("Company" => "Boots 'R Us", "Title" => "CEO");
ldap_modify($connection, $dn, $attrs);
?– Note The ldap_mod_replace() function is an alias to ldap_modify().
Renaming Entries
The ldap_rename() function is used to rename an existing entry. Its prototype follows:
boolean ldap_rename(resource link_id, string dn, string new_rdn,
string new_parent, boolean delete_old_rdn)
The new_parent parameter specifies the newly renamed entry??™s parent object. If
the parameter delete_old_rdn is set to TRUE, the old entry is deleted; otherwise, it will
remain in the directory as a nondistinguished value of the renamed entry.
Deleting LDAP Data
Although it is rare, data is occasionally removed from the directory. Deletion can take
place on two levels??”removal of an entire object, or removal of attributes associated
with an object. Two functions are available for performing these tasks, ldap_delete()
and ldap_mod_del(), respectively. Both are introduced in this section.
CHAPTER 17 ?– PHP A ND LDAP 439
Deleting Entries
The ldap_delete() function removes an entire entry from the LDAP directory, returning
TRUE on success and FALSE on failure. Its prototype follows:
boolean ldap_delete(resource link_id, string dn)
An example follows:
$dn = "cn=John Wayne,ou=People,dc=OpenLDAP,dc=org";
ldap_delete($connection, $dn) or die("Could not delete entry!");
Completely removing a directory object is rare; you??™ll probably want to remove
object attributes rather than an entire object.
Pages:
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518