summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-01-17 11:38:10 (GMT)
committerAleksander Machniak <alec@alec.pl>2014-01-17 11:38:10 (GMT)
commitcc55b74f68a7e90c4aa5d972c2fda54c5b4e586c (patch)
treeb3e2b26f8832b6313870aef8d7e6241b987443c6
parenta4b33a9ccb881ffeb8e5151be1753cf6eec11c82 (diff)
downloadNet_LDAP3-cc55b74f68a7e90c4aa5d972c2fda54c5b4e586c.tar.gz
Add delete_entry_recursive() method
-rw-r--r--lib/Net/LDAP3.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index 6cfedfe..b7cba98 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -677,7 +677,6 @@ class Net_LDAP3
if (ldap_delete($this->conn, $entry_dn) === false) {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
- $this->_debug("LDAP: Delete failed. " . ldap_error($this->conn));
return false;
}
@@ -686,6 +685,32 @@ class Net_LDAP3
return true;
}
+ /**
+ * Deletes specified entry and all entries in the tree
+ */
+ public function delete_entry_recursive($entry_dn)
+ {
+ // searching for sub entries, but not scope sub, just one level
+ $this->config_set('return_attributes', array('entrydn'));
+ $result = $this->search($entry_dn, '(objectclass=*)', 'one');
+
+ if ($result) {
+ $entries = $result->entries(true);
+
+ foreach (array_keys($entries) as $sub_dn) {
+ if (!$this->delete_entry_recursive($sub_dn)) {
+ return false;
+ }
+ }
+ }
+
+ if (!$this->delete_entry($entry_dn)) {
+ return false;
+ }
+
+ return true;
+ }
+
public function effective_rights($subject)
{
$effective_rights_control_oid = "1.3.6.1.4.1.42.2.27.9.5.2";
@@ -1344,7 +1369,6 @@ class Net_LDAP3
if ($result) {
return $mod_array;
}
-
}
/**