From b8e0c0124daa81bf9720942c6846442b9a7f7c79 Mon Sep 17 00:00:00 2001 From: Martin van Es Date: Wed, 6 Dec 2023 12:16:06 +0100 Subject: [PATCH] Always create flat DN --- plsc_flat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plsc_flat.py b/plsc_flat.py index b9d7fc1..9ef14d0 100755 --- a/plsc_flat.py +++ b/plsc_flat.py @@ -36,6 +36,18 @@ def create(src, dst): dst_entries = {} logging.debug("service: {}".format(service)) + + # Create flat dn if it doesn't exist + flat_dns = dst.rfind(f"dc={service}", "(&(objectClass=dcObject)(dc=flat))") + if len(flat_dns) == 0: + flat_dn = f"dc=flat,dc={service},{dst.basedn}" + flat_entry = {'objectClass': ['dcObject', 'organizationalUnit'], 'dc': ['flat'], 'ou': ['flat']} + dst.add(flat_dn, flat_entry) + for ou in ['Groups', 'People']: + ou_dn = 'ou=' + ou + ',' + flat_dn + ou_entry = {'objectClass': ['top', 'organizationalUnit'], 'ou': [ou]} + dst.add(ou_dn, ou_entry) + for co_id in cos: logging.debug(f"- co: {co_id}")