summaryrefslogtreecommitdiffstats
path: root/lib/ext/Net/LDAP3.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext/Net/LDAP3.php')
-rw-r--r--lib/ext/Net/LDAP3.php41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 52d8626..674f261 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1228,8 +1228,7 @@ class Net_LDAP3
// TODO: Get $rdn_attr - we have type_id in $new_attrs
$dn_components = ldap_explode_dn($subject_dn, 0);
$rdn_components = explode('=', $dn_components[0]);
-
- $rdn_attr = $rdn_components[0];
+ $rdn_attr = $rdn_components[0];
$this->_debug("Net_LDAP3::modify_entry() using rdn attribute: " . $rdn_attr);
@@ -1363,6 +1362,11 @@ class Net_LDAP3
}
foreach ($new_attrs as $attr => $value) {
+ // OU's parent base dn
+ if ($attr == 'base_dn') {
+ continue;
+ }
+
if (is_array($value)) {
if (count($value) == 1) {
$new_attrs[$attr] = $value[0];
@@ -1420,21 +1424,28 @@ class Net_LDAP3
$old_ou = implode(',', $subject_dn_components);
}
- if ((!empty($old_ou) || !empty($new_ou)) && strtolower($old_ou) !== strtolower($new_ou)) {
- // object is an organizational unit
- if (strpos($subject_dn, 'ou=' . $old_ou) === 0) {
- $mod_array['rename']['new_parent'] = substr($subject_dn, strlen('ou=' . $old_ou) + 1);
- if (empty($mod_array['rename']['dn']) || empty($mod_array['rename']['new_rdn'])) {
- $mod_array['rename']['dn'] = $subject_dn;
- $mod_array['rename']['new_rdn'] = 'ou=' . $new_ou;
+ // object is an organizational unit
+ if (strpos($subject_dn, 'ou=' . $old_ou) === 0) {
+ $root = substr($subject_dn, strlen($old_ou) + 4); // remove ou=*,
+
+ if ((!empty($new_attrs['base_dn']) && strtolower($new_attrs['base_dn']) !== strtolower($root))
+ || (strtolower($old_ou) !== strtolower($new_ou))
+ ) {
+ if (!empty($new_attrs['base_dn'])) {
+ $root = $new_attrs['base_dn'];
}
+
+ $mod_array['rename']['new_parent'] = $root;
+ $mod_array['rename']['dn'] = $subject_dn;
+ $mod_array['rename']['new_rdn'] = 'ou=' . $new_ou;
}
- else {
- $mod_array['rename']['new_parent'] = $new_ou;
- if (empty($mod_array['rename']['dn']) || empty($mod_array['rename']['new_rdn'])) {
- $mod_array['rename']['dn'] = $subject_dn;
- $mod_array['rename']['new_rdn'] = $rdn_attr . '=' . $new_attrs[$rdn_attr];
- }
+ }
+ // not OU object, but changed ou attribute
+ else if ((!empty($old_ou) || !empty($new_ou)) && strtolower($old_ou) !== strtolower($new_ou)) {
+ $mod_array['rename']['new_parent'] = $new_ou;
+ if (empty($mod_array['rename']['dn']) || empty($mod_array['rename']['new_rdn'])) {
+ $mod_array['rename']['dn'] = $subject_dn;
+ $mod_array['rename']['new_rdn'] = $rdn_attr . '=' . $new_attrs[$rdn_attr];
}
}