Esempio n. 1
0
BOOL test_DsRoleGetPrimaryDomainInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
	struct dssetup_DsRoleGetPrimaryDomainInformation r;
	NTSTATUS status;
	BOOL ret = True;
	int i;

	printf("\ntesting DsRoleGetPrimaryDomainInformation\n");

	for (i=DS_ROLE_BASIC_INFORMATION; i <= DS_ROLE_OP_STATUS; i++) {
		r.in.level = i;

		status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, mem_ctx, &r);
		if (!NT_STATUS_IS_OK(status)) {
			const char *errstr = nt_errstr(status);
			if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
				errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
			}
			printf("dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
				i, errstr);
			ret = False;
		} else if (!W_ERROR_IS_OK(r.out.result)) {
			printf("DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
				i, win_errstr(r.out.result));
			ret = False;
		}
	}

	return ret;
}
Esempio n. 2
0
static WERROR cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli,
					      TALLOC_CTX *mem_ctx, int argc,
					      const char **argv)
{
	struct dcerpc_binding_handle *b = cli->binding_handle;
	NTSTATUS status;
	WERROR werr;
	union dssetup_DsRoleInfo info;

	status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(b, mem_ctx,
								  DS_ROLE_BASIC_INFORMATION,
								  &info,
								  &werr);
	if (!NT_STATUS_IS_OK(status)) {
		return ntstatus_to_werror(status);
	}

	if (!W_ERROR_IS_OK(werr)) {
		return werr;
	}

	printf ("Machine Role = [%d]\n", info.basic.role);

	if (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING) {
		printf("Directory Service is running.\n");
		printf("Domain is in %s mode.\n",
			(info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
	} else {
		printf("Directory Service not running on server\n");
	}

	return werr;
}
Esempio n. 3
0
NTSTATUS net_scan_dc(struct net_context *c,
		     struct cli_state *cli,
		     struct net_dc_info *dc_info)
{
	TALLOC_CTX *mem_ctx = talloc_tos();
	struct rpc_pipe_client *dssetup_pipe = NULL;
	struct dcerpc_binding_handle *dssetup_handle = NULL;
	union dssetup_DsRoleInfo info;
	NTSTATUS status;
	WERROR werr;

	ZERO_STRUCTP(dc_info);

	status = cli_rpc_pipe_open_noauth(cli, &ndr_table_dssetup.syntax_id,
					  &dssetup_pipe);
        if (!NT_STATUS_IS_OK(status)) {
		DEBUG(10,("net_scan_dc: failed to open dssetup pipe with %s, "
			"retrying with lsa pipe\n", nt_errstr(status)));
		return net_scan_dc_noad(c, cli, dc_info);
	}
	dssetup_handle = dssetup_pipe->binding_handle;

	status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(dssetup_handle, mem_ctx,
								  DS_ROLE_BASIC_INFORMATION,
								  &info,
								  &werr);
	TALLOC_FREE(dssetup_pipe);

	if (NT_STATUS_IS_OK(status)) {
		status = werror_to_ntstatus(werr);
	}
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	dc_info->is_dc	= (info.basic.role & (DS_ROLE_PRIMARY_DC|DS_ROLE_BACKUP_DC));
	dc_info->is_pdc	= (info.basic.role & DS_ROLE_PRIMARY_DC);
	dc_info->is_ad	= (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING);
	dc_info->is_mixed_mode = (info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE);
	dc_info->netbios_domain_name = talloc_strdup(mem_ctx, info.basic.domain);
	dc_info->dns_domain_name = talloc_strdup(mem_ctx, info.basic.dns_domain);
	dc_info->forest_name = talloc_strdup(mem_ctx, info.basic.forest);

	return NT_STATUS_OK;
}