Home arrow PHP arrow Page 6 - Using PHP With LDAP (part 2)

Wiping Out The Past - PHP

In this second, and concluding, article, dig deeper into PHP'sLDAP API by writing complex search queries and building a Web-basedadministration module to retrieve and modify entries from the LDAP directorytree.

  1. Using PHP With LDAP (part 2)
  2. Of Needles And Haystacks
  3. Making Lists
  4. Adding It All Up
  5. Changing Things Around
  6. Wiping Out The Past
  7. To Err Is Human...
  8. Endgame
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 9
April 07, 2003

print this article


So that takes care of listing, adding and modifying entries. All that's left is to delete entries.

Again, this is similar to modifying entries - "delete.php", the script to invoke entry deletion is accessed from the main index page, and is passed the user's email address using the URL GET method. This email address is then used by the PHP script to identify the corresponding entry and remove it via the ldap_delete() command.

<html> <head> </head> <body> <?php // specify the LDAP server to connect to $conn = ldap_connect("localhost") or die("Could not connect to server. Error is " . ldap_error($conn)); // set privileged user $root_dn = "cn=root, dc=my-domain, dc=com"; $root_pw = "secret"; // bind to the LDAP server specified above $r = ldap_bind($conn, $root_dn, $root_pw) or die("Could not bind to server. Error is " . ldap_error($conn)); // prepare DN for entry to delete $dn = "mail=".$_GET['mail'].", dc=my-domain, dc=com"; // delete the entry from the directory $result=ldap_delete($conn, $dn) ; // if successful, display success message if($result) { echo "Entry with DN " . $dn . " deleted from LDAP directory."; } // else display error else { echo "An error occurred. Error number " . ldap_errno($conn) . ": " . ldap_err2str(ldap_errno($conn)); } // all done? clean up ldap_close($conn); ?> </body> </html>
Here's the output:

>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: