Skip to content

Commit

Permalink
Merge pull request #125 from SURFscz/fix-flat-hierarchy
Browse files Browse the repository at this point in the history
Always create flat DN
  • Loading branch information
baszoetekouw authored Dec 6, 2023
2 parents 41a1a58 + faf65ca commit cd14292
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions plsc_flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand All @@ -46,17 +58,6 @@ def create(src, dst):

co_dn = f"dc=flat,dc={service},{dst.basedn}"

# 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)

logging.debug(" - People")
src_dns = src.rfind(f"ou=People,o={co_id},dc=ordered,dc={service}", '(ObjectClass=person)')

Expand Down

0 comments on commit cd14292

Please sign in to comment.