TechniqueUse the ldap_delete() function to delete object-level entries on your LDAP server: <?php // connect and bind, notice the password is specified // when we bind the connection $lh = ldap_connect("localhost") or die("Cannot connect to LDAP server"); ldap_bind($lh, "cn=root, o=Sterling's Company, c=US", "password") or die("Cannot Bind"); // delete and close ldap_delete($lh, "cn=Doc Brown, o=Sterling's Company, c=US"); ldap_close($lh); ?> CommentsIn this script, we delete the person Doc Brown from our directory. Doing so removes not only his entry but also all attributes associated with his entry. This is achieved by using the ldap_delete() function, which enables you to delete object-level entries from an LDAP server. If you want to delete attributes from a specific dn , use the ldap_mod_del() function instead: <?php $lh = ldap_connect("localhost") or die("Cannot connect to LDAP server"); ldap_bind($lh, "cn=root, o=Sterling's Company, c=US", "password") or die("Cannot Bind to LDAP server"); $delete_data = array("sn", "mail"); ldap_mod_del($lh, "cn=Doc Brown, o=Sterling's Company, c=US", $delete_data); ldap_close($lh); ?> |