diff options
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/join.py | 20 | ||||
-rw-r--r-- | source4/scripting/python/samba/provision/__init__.py | 12 |
2 files changed, 18 insertions, 14 deletions
diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py index 533c88dd62..dfa8bf9e0d 100644 --- a/source4/scripting/python/samba/join.py +++ b/source4/scripting/python/samba/join.py @@ -83,6 +83,7 @@ class dc_join(object): ctx.config_dn = str(ctx.samdb.get_config_basedn()) ctx.domsid = ctx.samdb.get_domain_sid() ctx.domain_name = ctx.get_domain_name() + ctx.invocation_id = misc.GUID(str(uuid.uuid4())) ctx.dc_ntds_dn = ctx.get_dsServiceName() ctx.dc_dnsHostName = ctx.get_dnsHostName() @@ -375,7 +376,7 @@ class dc_join(object): if ctx.behavior_version >= samba.dsdb.DS_DOMAIN_FUNCTION_2003: rec["msDS-HasMasterNCs"] = nc_list rec["options"] = "1" - rec["invocationId"] = ndr_pack(misc.GUID(str(uuid.uuid4()))) + rec["invocationId"] = ndr_pack(ctx.invocation_id) if ctx.subdomain: ctx.samdb.add(rec, ['relax:0']) else: @@ -512,6 +513,8 @@ class dc_join(object): "dnsRoot": ctx.dnsdomain, "trustParent" : ctx.parent_partition_dn, "systemFlags" : str(samba.dsdb.SYSTEM_FLAG_CR_NTDS_NC|samba.dsdb.SYSTEM_FLAG_CR_NTDS_DOMAIN)} + if ctx.behavior_version >= samba.dsdb.DS_DOMAIN_FUNCTION_2003: + rec["msDS-Behavior-Version"] = str(ctx.behavior_version) ctx.DsAddEntry(rec) @@ -543,8 +546,15 @@ class dc_join(object): def join_provision_own_domain(ctx): '''provision the local SAM''' - # we now operate exclusively on the local database - ctx.samdb = ctx.local_samdb + # we now operate exclusively on the local database, which + # we need to reopen in order to get the newly created schema + print("Reconnecting to local samdb") + ctx.samdb = SamDB(url=ctx.local_samdb.url, + session_info=system_session(), + lp=ctx.local_samdb.lp, + global_schema=False) + ctx.samdb.set_invocation_id(str(ctx.invocation_id)) + ctx.local_samdb = ctx.samdb ctx.join_add_ntdsdsa() @@ -560,7 +570,7 @@ class dc_join(object): domainguid=ctx.domguid, targetdir=ctx.targetdir, samdb_fill=FILL_SUBDOMAIN, machinepass=ctx.acct_pass, serverrole="domain controller", - lp=ctx.lp) + lp=ctx.lp, hostip=ctx.names.hostip, hostip6=ctx.names.hostip6) print("Provision OK for domain %s" % ctx.names.dnsdomain) @@ -770,8 +780,8 @@ class dc_join(object): try: ctx.join_add_objects() ctx.join_provision() - ctx.join_replicate() ctx.join_add_objects2() + ctx.join_replicate() if ctx.subdomain: ctx.join_provision_own_domain() ctx.join_setup_trusts() diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 827d72b5e4..0b39167df4 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -1345,15 +1345,6 @@ def fill_samdb(samdb, lp, names, else: samdb.transaction_commit() - samdb = SamDB(session_info=admin_session_info, auto_connect=False, - credentials=provision_backend.credentials, lp=lp, - global_schema=False, am_rodc=am_rodc) - - # Set the NTDS settings DN manually - in order to have it already around - # before the provisioned tree exists and we connect - samdb.set_ntds_settings_dn("CN=NTDS Settings,%s" % names.serverdn) - samdb.connect(path) - samdb.transaction_start() try: samdb.invocation_id = invocationid @@ -1802,6 +1793,9 @@ def provision(logger, session_info, credentials, smbconf=None, if hostip6 is None: logger.warning("No IPv6 address will be assigned") + names.hostip = hostip + names.hostip6 = hostip6 + if serverrole is None: serverrole = lp.get("server role") |