from .config import LDAPMigrationConfiguration
-__version__ = '0.10.7'
+__version__ = '0.10.8'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
LOG.info("Creating target entry {!r} ...".format(tgt_dn))
if self.verbose > 2:
msg = "Generated entry for target DN {dn!r}:\n"
- msg += "object classes: {oc}\n"
- msg += "entry: {en}"
+ msg += "object classes:\n{oc}\n"
+ msg += "entry:\n{en}"
msg = msg.format(dn=tgt_dn, oc=tgt_obj_classes, en=tgt_entry)
LOG.debug(msg)
self.count_added += 1
cr_status, cr_result, cr_response, _ = self.target.add(
tgt_dn, object_class=tgt_obj_classes, attributes=tgt_entry)
except LDAPException as e:
- msg = "Modifying NOT successfull - {c}: {e}\n"
+ msg = "Creation NOT successfull - {c}: {e}\n"
msg += "Source attributes:\n{sattr}\n"
msg += "Target-DN: {dn!r}\n"
msg += "Target Object classes:\n{ocs}\n"
tgt_oc_name = self.object_classes.real_key(src_oc_name)
used_classes.add(tgt_oc_name)
+ # Migrating all normal attributes
+ for attribute_name in src_data['attributes']:
+ if attribute_name not in self.attribute_types:
+ if self.verbose > 3:
+ msg = "AttributeType {at!r} of sorce entry {dn!r} not found "
+ msg += "on target LDAP server."
+ msg = msg.format(at=attribute_name, dn=src_dn)
+ LOG.debug(msg)
+ continue
+ if ('obsolete' in self.attribute_types[attribute_name] and
+ self.attribute_types[attribute_name]['obsolete']):
+ if self.verbose > 1:
+ msg = "AttributeType {at!r} of sorce entry {dn!r} is obsolete.".format(
+ at=attribute_name, dn=src_dn)
+ LOG.debug(msg)
+ continue
+ tgt_at_name = self.attribute_types.real_key(attribute_name)
+ for single_attr in src_data['attributes'][attribute_name]:
+ if single_attr == '':
+ continue
+ if tgt_at_name not in target_entry:
+ target_entry[tgt_at_name] = []
+ if attribute_name in self.boolean_attr_types:
+ if to_bool(single_attr):
+ single_attr = 'TRUE'
+ else:
+ single_attr = 'FALSE'
+ target_entry[tgt_at_name].append(single_attr)
+
+ # We are only supporting groupOfUniqueNames
+ tgt_oc_name = self.object_classes.real_key('groupOfUniqueNames')
+ used_classes.add(tgt_oc_name)
members = src_data['members']
- if 'groupOfURLs' in src_data['classes']:
- if self.name_group_classes.isdisjoint(src_data['classes']):
- members.clear()
- tgt_oc_name = self.object_classes.real_key('groupOfURLs')
- used_classes.add(tgt_oc_name)
- if len(src_data['member_url']):
- tgt_at_name = self.attribute_types.real_key('memberURL')
- target_entry[tgt_at_name] = copy.copy(src_data['member_url'])
- else:
- tgt_oc_name = self.object_classes.real_key('groupOfUniqueNames')
- used_classes.add(tgt_oc_name)
- if len(src_data['member_url']):
- dyn_members = self.get_dyn_members(src_data['member_url'])
- for member in dyn_members:
- members.add(member)
- else:
- tgt_oc_name = self.object_classes.real_key('groupOfUniqueNames')
- used_classes.add(tgt_oc_name)
+ if 'groupOfURLs' in src_data['classes'] and len(src_data['member_url']):
+ dyn_members = self.get_dyn_members(src_data['member_url'])
+ for member in dyn_members:
+ members.add(member)
if len(members):
tgt_at_name = self.attribute_types.real_key('uniqueMember')