|
2394 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: modify object: %s"%object['dn']) |
2394 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: modify object: %s"%object['dn']) |
2395 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: old_object: %s" % old_ucs_object) |
2395 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: old_object: %s" % old_ucs_object) |
2396 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: new_object: %s" % new_ucs_object) |
2396 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: new_object: %s" % new_ucs_object) |
|
|
2397 |
try: |
2398 |
## try to fetch the latest version of the OpenLDAP object |
2399 |
current_ucs_object = self.lo.get(object['dn']) |
2400 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: cur_object: %s" % current_ucs_object) |
2401 |
new_ucs_object = current_ucs_object |
2402 |
except ldap.NO_SUCH_OBJECT: |
2403 |
pass |
2397 |
object['old_ucs_object'] = old_ucs_object |
2404 |
object['old_ucs_object'] = old_ucs_object |
2398 |
object['new_ucs_object'] = new_ucs_object |
2405 |
object['new_ucs_object'] = new_ucs_object |
|
|
2406 |
|
2399 |
attribute_list = set(old_ucs_object.keys()).union(set(new_ucs_object.keys())) |
2407 |
attribute_list = set(old_ucs_object.keys()).union(set(new_ucs_object.keys())) |
2400 |
if hasattr(self.property[property_type],"con_sync_function"): |
2408 |
if hasattr(self.property[property_type],"con_sync_function"): |
2401 |
self.property[property_type].con_sync_function(self, property_type, object) |
2409 |
self.property[property_type].con_sync_function(self, property_type, object) |
|
2438 |
modify=True |
2446 |
modify=True |
2439 |
|
2447 |
|
2440 |
if not modify: |
2448 |
if not modify: |
2441 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: no modification necessary for %s" % attribute) |
2449 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: values did not change for %s" % attribute) |
2442 |
continue |
2450 |
continue |
2443 |
|
2451 |
|
|
|
2452 |
current_s4_values = set(s4_object.get(s4_attribute, [])) |
2453 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) |
2454 |
|
2444 |
# So, at this point we have the old and the new UCS object. |
2455 |
# So, at this point we have the old and the new UCS object. |
2445 |
# Thus we can create the diff, but we have to check the current S4 object |
2456 |
# Thus we can create the diff, but we have to check the current S4 object |
2446 |
|
2457 |
|
|
2456 |
|
2467 |
|
2457 |
if s4_other_attribute: |
2468 |
if s4_other_attribute: |
2458 |
# in this case we need lists because sets are unorded and the order is important |
2469 |
# in this case we need lists because sets are unorded and the order is important |
2459 |
current_s4_values = set(s4_object.get(s4_attribute, [])) |
|
|
2460 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) |
2461 |
|
2462 |
current_s4_other_values = set(s4_object.get(s4_other_attribute, [])) |
2470 |
current_s4_other_values = set(s4_object.get(s4_other_attribute, [])) |
2463 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 other values: %s" % current_s4_other_values) |
2471 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 other values: %s" % current_s4_other_values) |
2464 |
|
2472 |
|
|
2480 |
if current_s4_other_values != new_s4_other_values: |
2488 |
if current_s4_other_values != new_s4_other_values: |
2481 |
modlist.append((ldap.MOD_REPLACE, s4_other_attribute, new_s4_other_values)) |
2489 |
modlist.append((ldap.MOD_REPLACE, s4_other_attribute, new_s4_other_values)) |
2482 |
else: |
2490 |
else: |
2483 |
current_s4_values = set(s4_object.get(s4_attribute, [])) |
|
|
2484 |
|
2485 |
ud.debug(ud.LDAP, ud.INFO, "sync_from_ucs: The current S4 values: %s" % current_s4_values) |
2486 |
|
2487 |
if (to_add or to_remove) and attribute_type[attribute].single_value: |
2491 |
if (to_add or to_remove) and attribute_type[attribute].single_value: |
2488 |
modify=False |
2492 |
modify=False |
2489 |
if not current_s4_values or not value: |
2493 |
if not current_s4_values or not value: |