11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 17 • <strong>PHP</strong> AND LDAPproperly because you don’t possess adequate privileges to modify users residing in the WJGilmoredirectory:$dn = "ou=People,dc=WJGilmore,dc=com";$entry["mail"][] = "pilgrim@example.com";ldap_mod_add($connection, $dn, $entry)or die("Can't add entry attribute value!");Note that the $dn has changed here because you need to make specific reference to John Wayne’sdirectory entry.Suppose that John now wants to add his title to the directory. Because the title attribute is singlevaluedit can be added like so:$dn = "cn=John Wayne,ou=People,dc=WJGilmore,dc=com";$entry["title"] = "Ranch Hand";ldap_mod_add($connection, $dn, $entry) or die("Can't add new value!");Updating LDAP DataAlthough LDAP data is intended to be largely static, changes are sometimes necessary. <strong>PHP</strong> offers twofunctions for carrying out such modifications: ldap_modify() for making changes on the attribute level,and ldap_rename() for making changes on the object level.Modifying EntriesThe ldap_modify() function is used to modify existing directory entry attributes, returning TRUE onsuccess and FALSE on failure. Its prototype follows:Boolean ldap_modify(resource link_id, string dn, array entry)With this function, you can modify one or several attributes simultaneously. Consider an example:$dn = "cn=John Wayne,ou=People,dc=WJGilmore,dc=com";$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 EntriesThe 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)361

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!