Beispiel #1
0
 def test_repr(self):
     x = misc.policy_handle(text1, 42)
     self.assertEqual("policy_handle(%d, '%s')" % (42, text1), repr(x))
Beispiel #2
0
 def test_str(self):
     x = misc.policy_handle(text1, 42)
     self.assertEqual("%d, %s" % (42, text1), str(x))
Beispiel #3
0
 def test_str(self):
     x = misc.policy_handle(text1, 42)
     self.assertEquals("%d, %s" % (42, text1), str(x))
Beispiel #4
0
 def test_init(self):
     x = misc.policy_handle(text1, 1)
     self.assertEqual(1, x.handle_type)
     self.assertEqual(text1, str(x.uuid))
Beispiel #5
0
 def test_repr(self):
     x = misc.policy_handle(text1, 42)
     self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x))
Beispiel #6
0
 def test_init(self):
     x = misc.policy_handle(text1, 1)
     self.assertEquals(1, x.handle_type)
     self.assertEquals(text1, str(x.uuid))
Beispiel #7
0
    def run(self, DEST_DC, SOURCE_DC, NC,
            add_ref=False, sync_forced=False, sync_all=False, full_sync=False,
            local=False, local_online=False, async_op=False, single_object=False,
            sambaopts=None, credopts=None, versionopts=None):

        self.server = DEST_DC
        self.lp = sambaopts.get_loadparm()

        self.creds = credopts.get_credentials(self.lp, fallback_machine=True)

        if local:
            self.drs_local_replicate(SOURCE_DC, NC, full_sync=full_sync,
                                     single_object=single_object,
                                     sync_forced=sync_forced)
            return

        if local_online:
            server_bind = drsuapi.drsuapi("irpc:dreplsrv", lp_ctx=self.lp)
            server_bind_handle = misc.policy_handle()
        else:
            drsuapi_connect(self)
            server_bind = self.drsuapi
            server_bind_handle = self.drsuapi_handle

        if not async_op:
            # Give the sync replication 5 minutes time
            server_bind.request_timeout = 5 * 60

        samdb_connect(self)

        # we need to find the NTDS GUID of the source DC
        msg = self.samdb.search(base=self.samdb.get_config_basedn(),
                                expression="(&(objectCategory=server)(|(name=%s)(dNSHostName=%s)))" % (
            ldb.binary_encode(SOURCE_DC),
            ldb.binary_encode(SOURCE_DC)),
                                attrs=[])
        if len(msg) == 0:
            raise CommandError("Failed to find source DC %s" % SOURCE_DC)
        server_dn = msg[0]['dn']

        msg = self.samdb.search(base=server_dn, scope=ldb.SCOPE_ONELEVEL,
                                expression="(|(objectCategory=nTDSDSA)(objectCategory=nTDSDSARO))",
                                attrs=['objectGUID', 'options'])
        if len(msg) == 0:
            raise CommandError("Failed to find source NTDS DN %s" % SOURCE_DC)
        source_dsa_guid = msg[0]['objectGUID'][0]
        dsa_options = int(attr_default(msg, 'options', 0))


        req_options = 0
        if not (dsa_options & dsdb.DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL):
            req_options |= drsuapi.DRSUAPI_DRS_WRIT_REP
        if add_ref:
            req_options |= drsuapi.DRSUAPI_DRS_ADD_REF
        if sync_forced:
            req_options |= drsuapi.DRSUAPI_DRS_SYNC_FORCED
        if sync_all:
            req_options |= drsuapi.DRSUAPI_DRS_SYNC_ALL
        if full_sync:
            req_options |= drsuapi.DRSUAPI_DRS_FULL_SYNC_NOW
        if async_op:
            req_options |= drsuapi.DRSUAPI_DRS_ASYNC_OP

        try:
            drs_utils.sendDsReplicaSync(server_bind, server_bind_handle, source_dsa_guid, NC, req_options)
        except drs_utils.drsException as estr:
            raise CommandError("DsReplicaSync failed", estr)
        if async_op:
            self.message("Replicate from %s to %s was started." % (SOURCE_DC, DEST_DC))
        else:
            self.message("Replicate from %s to %s was successful." % (SOURCE_DC, DEST_DC))
Beispiel #8
0
 def test_str(self):
     x = misc.policy_handle(text1, 42)
     self.assertEquals("{0:d}, {1!s}".format(42, text1), str(x))
Beispiel #9
0
 def test_repr(self):
     x = misc.policy_handle(text1, 42)
     self.assertEquals("policy_handle({0:d}, '{1!s}')".format(42, text1), repr(x))