From: Frank Brehm Date: Thu, 11 Mar 2021 07:53:42 +0000 (+0100) Subject: Continuing migration of group entries X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=ee4fd9ec7eec5adb7bc97bbb8f022be1019114b4;p=pixelpark%2Fldap-migration.git Continuing migration of group entries --- diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index 8359d84..5d898f3 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -47,7 +47,7 @@ from fb_tools.collections import FrozenCIStringSet, CIStringSet, CIDict from .config import LDAPMigrationConfiguration -__version__ = '0.10.7' +__version__ = '0.10.8' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -1982,8 +1982,8 @@ class LDAPMigrationApplication(BaseApplication): 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 @@ -1992,7 +1992,7 @@ class LDAPMigrationApplication(BaseApplication): 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" @@ -2031,26 +2031,44 @@ class LDAPMigrationApplication(BaseApplication): 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')