#!/bin/sh
[ -z "$1" ] && echo "Usage: $0 <base DN>" && exit 1

stop samba-ad-dc
for schema in *.ldif; do
    echo "Loading: $schema"
    cat $schema | sed "s/DC=X/$1/g" | ldbmodify -H /var/lib/samba/private/sam.ldb - --option="dsdb:schema update allowed"=true
done
start samba-ad-dc
