Skip to content

Commit

Permalink
Merge pull request #46 from NethServer/bug-7101
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePrincipi authored Dec 6, 2024
2 parents 840c4fc + 64590cb commit f452aad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ payload structure.

## Migration notes

- The NS7 domain is migrated as `directory.nh`
- On the NS7 side a Python filter `ns8fixschema.py` converts the LDIF dump
to a NS8 compatible schema. The script `utils/genschema.py` was used to
export NS8 schema data in Python format.
- The password policy feature does not exist in NS7. When the NS7 LDAP
account provider is migrated to NS8 the password policy is set in a
disabled state and can be enabled later from the Domains and Users page
Expand Down
2 changes: 1 addition & 1 deletion server/usr/local/bin/new-domain
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ slapadd -v -w -S "${LDAP_SERVERID}" -n 0 -F conf.d < <(envsubst <"${TEMPLATES_DI

if [ -f dump-mdb0.ldif ]; then
echo "Restoring ${LDAP_SUFFIX} database for ${LDAP_DOMAIN}"
slapadd -v -F conf.d -b "${LDAP_SUFFIX}" -l dump-mdb0.ldif
slapadd -v -c -F conf.d -b "${LDAP_SUFFIX}" -l dump-mdb0.ldif
else
echo "Creating ${LDAP_SUFFIX} database for ${LDAP_DOMAIN}"
slapadd -v -w -S "${LDAP_SERVERID}" -b "${LDAP_SUFFIX}" -F conf.d < <(envsubst <"${TEMPLATES_DIR}/mdb0.ldif" | tee dump-mdb0.ldif)
Expand Down
34 changes: 34 additions & 0 deletions utils/genschema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import ldap3
import sys
import json
import agent
import os

from agent.ldapproxy import Ldapproxy

#
# Fetch the LDAP schema and dump it as a Python dictionary The output of
# this script is useful to build a Python schema conversion filter, to
# migrate from an NS6-LDAP to NS8.
#

def print_schema_pydict():
lp = Ldapproxy()

config = lp.get_domain(os.environ["LDAP_DOMAIN"])
server = ldap3.Server(config['host'],port=int(config['port']), get_info=ldap3.ALL)
conn = ldap3.Connection(server, user=config["bind_dn"], password=config["bind_password"], auto_bind=True)

print("ns8schema = {")
for cl in server.schema.object_classes:
co = ldap3.ObjectDef([cl], conn)
print(" " + repr(cl) + ': ' + repr([x.name for x in co]) + ",")
print("}")

if __name__ == '__main__':
print_schema_pydict()

0 comments on commit f452aad

Please sign in to comment.