mirror of
https://github.com/samba-team/samba.git
synced 2025-12-19 12:23:49 +03:00
samba-tool: Add new command 'samba-tool drs clone-dc-database'
This command makes a clone of an existing AD Domain, but does not join the domain. This allows us to test if the join would work without adding objects to the target DC. The server password will need to be reset for the clone to be any use, see the source4/scripting/devel/chgtdcpass (Based on patches written with Garming Sam) Andrew Bartlett Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
import samba.getopt as options
|
||||
import ldb
|
||||
import logging
|
||||
|
||||
from samba.auth import system_session
|
||||
from samba.netcmd import (
|
||||
@@ -32,6 +33,7 @@ from samba.samdb import SamDB
|
||||
from samba import drs_utils, nttime2string, dsdb
|
||||
from samba.dcerpc import drsuapi, misc
|
||||
import common
|
||||
from samba.join import join_clone
|
||||
|
||||
def drsuapi_connect(ctx):
|
||||
'''make a DRSUAPI connection to the server'''
|
||||
@@ -513,6 +515,44 @@ class cmd_drs_options(Command):
|
||||
self.message("New DSA options: " + ", ".join(cur_opts))
|
||||
|
||||
|
||||
class cmd_drs_clone_dc_database(Command):
|
||||
"""Replicate an initial clone of domain, but DO NOT JOIN it."""
|
||||
|
||||
synopsis = "%prog <dnsdomain> [options]"
|
||||
|
||||
takes_optiongroups = {
|
||||
"sambaopts": options.SambaOptions,
|
||||
"versionopts": options.VersionOptions,
|
||||
"credopts": options.CredentialsOptions,
|
||||
}
|
||||
|
||||
takes_options = [
|
||||
Option("--server", help="DC to join", type=str),
|
||||
Option("--targetdir", help="where to store provision", type=str),
|
||||
Option("--quiet", help="Be quiet", action="store_true"),
|
||||
Option("--verbose", help="Be verbose", action="store_true")
|
||||
]
|
||||
|
||||
takes_args = ["domain"]
|
||||
|
||||
def run(self, domain, sambaopts=None, credopts=None,
|
||||
versionopts=None, server=None, targetdir=None,
|
||||
quiet=False, verbose=False):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
|
||||
logger = self.get_logger()
|
||||
if verbose:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
elif quiet:
|
||||
logger.setLevel(logging.WARNING)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
join_clone(logger=logger, server=server, creds=creds, lp=lp, domain=domain,
|
||||
targetdir=targetdir)
|
||||
|
||||
|
||||
class cmd_drs(SuperCommand):
|
||||
"""Directory Replication Services (DRS) management."""
|
||||
|
||||
@@ -522,3 +562,4 @@ class cmd_drs(SuperCommand):
|
||||
subcommands["replicate"] = cmd_drs_replicate()
|
||||
subcommands["showrepl"] = cmd_drs_showrepl()
|
||||
subcommands["options"] = cmd_drs_options()
|
||||
subcommands["clone-dc-database"] = cmd_drs_clone_dc_database()
|
||||
|
||||
Reference in New Issue
Block a user