示例#1
0
int rpc_vampire_keytab(struct net_context *c, int argc, const char **argv)
{
	int ret = 0;
	NTSTATUS status;
	struct cli_state *cli = NULL;
	struct net_dc_info dc_info;

	if (c->display_usage || (argc < 1)) {
		d_printf("%s\n%s",
			 _("Usage:"),
			 _("net rpc vampire keytab <keytabfile>\n"
			   "    Dump remote SAM database to Kerberos keytab "
			   "file\n"));
		return 0;
	}

	status = net_make_ipc_connection(c, 0, &cli);
	if (!NT_STATUS_IS_OK(status)) {
		return -1;
	}

	status = net_scan_dc(c, cli, &dc_info);
	if (!NT_STATUS_IS_OK(status)) {
		return -1;
	}

	if (!dc_info.is_ad) {
		printf(_("DC is not running Active Directory\n"));
		ret = run_rpc_command(c, cli, &ndr_table_netlogon.syntax_id,
				      0,
				      rpc_vampire_keytab_internals, argc, argv);
		return -1;
	} else {
		ret = run_rpc_command(c, cli, &ndr_table_drsuapi.syntax_id,
				      NET_FLAGS_SEAL | NET_FLAGS_TCP,
				      rpc_vampire_keytab_ds_internals, argc, argv);
		if (ret != 0 && dc_info.is_mixed_mode) {
			printf(_("Fallback to NT4 vampire on Mixed-Mode AD "
				 "Domain\n"));
			ret = run_rpc_command(c, cli, &ndr_table_netlogon.syntax_id,
					      0,
					      rpc_vampire_keytab_internals, argc, argv);
		}
	}

	return ret;
}
示例#2
0
static int rpc_service_create(struct net_context *c, int argc, const char **argv)
{
	if (c->display_usage) {
		d_printf(_("Usage:\n"
			   "net rpc service create <service>\n"
			   "    Create a Win32 service\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
		rpc_service_create_internal, argc, argv);
}
示例#3
0
static int rpc_service_status(struct net_context *c, int argc, const char **argv )
{
	if (c->display_usage) {
		d_printf(_("Usage:\n"
			   "net rpc service status <service>\n"
			   "     Show the current status of a service\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
		rpc_service_status_internal, argc, argv );
}
示例#4
0
static int rpc_service_list(struct net_context *c, int argc, const char **argv )
{
	if (c->display_usage) {
		d_printf(_("Usage:\n"
			   "net rpc service list\n"
			   "    View configured Win32 services\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
		rpc_service_list_internal, argc, argv );
}
示例#5
0
int rpc_vampire_ldif(struct net_context *c, int argc, const char **argv)
{
	if (c->display_usage) {
		d_printf("Usage:\n"
			 "net rpc vampire ldif\n"
			 "    Dump remote SAM database to LDIF file or stdout\n");
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id, 0,
			       rpc_vampire_ldif_internals, argc, argv);
}
示例#6
0
static int rpc_rights_list(struct net_context *c, int argc, const char **argv )
{
	if (c->display_usage) {
		d_printf(_("Usage:\n"
			   "net rpc rights list [{accounts|privileges} "
			   "[name|SID]]\n"
			   "    View available/assigned privileges\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
		rpc_rights_list_internal, argc, argv );
}
示例#7
0
static int rpc_audit_list(struct net_context *c, int argc, const char **argv)
{
	if (c->display_usage) {
		d_printf( "%s\n"
			   "net rpc audit list\n"
			   "    %s\n",
			 _("Usage:"),
			 _("List auditing settings"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
		rpc_audit_list_internal, argc, argv);
}
示例#8
0
int rpc_vampire_passdb(struct net_context *c, int argc, const char **argv)
{
	if (c->display_usage) {
		d_printf(  "%s\n"
			   "net rpc vampire passdb\n"
			   "    %s\n",
			 _("Usage:"),
			 _("Dump remote SAM database to passdb"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id, 0,
			       rpc_vampire_internals, argc, argv);
}
示例#9
0
static int rpc_service_pause(struct net_context *c, int argc, const char **argv )
{
	if (c->display_usage) {
		d_printf(  "%s\n"
			   "net rpc service pause <service>\n"
			   "    %s\n",
			 _("Usage:"),
			 _("Pause a Win32 service"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
		rpc_service_pause_internal, argc, argv );
}
示例#10
0
static int rpc_rights_revoke(struct net_context *c, int argc, const char **argv)
{
	if (c->display_usage) {
		d_printf(_("Usage:\n"
			   "net rpc rights revoke <name|SID> <right>\n"
			   "    Revoke privilege[s]\n"));
		d_printf(_("For example:\n"
			   "    net rpc rights revoke 'VALE\\biddle' "
			   "SePrintOperatorPrivilege SeDiskOperatorPrivilege\n"
			   "    would revoke the printer admin and disk manager"
			   " rights from the user 'VALE\\biddle'\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
		rpc_rights_revoke_internal, argc, argv );
}
示例#11
0
static int rpc_rights_grant(struct net_context *c, int argc, const char **argv )
{
	if (c->display_usage) {
		d_printf("%s\n%s",
			 _("Usage:"),
			 _("net rpc rights grant <name|SID> <right>\n"
			   "    Assign privilege[s]\n"));
		d_printf(_("For example:\n"
			   "    net rpc rights grant 'VALE\\biddle' "
			   "SePrintOperatorPrivilege SeDiskOperatorPrivilege\n"
			   "    would grant the printer admin and disk manager "
			   "rights to the user 'VALE\\biddle'\n"));
		return 0;
	}

	return run_rpc_command(c, NULL, &ndr_table_lsarpc, 0,
		rpc_rights_grant_internal, argc, argv );
}
示例#12
0
static int net_printing_migrate(struct net_context *c,
				int argc,
				const char **argv)
{
	if (argc < 1 || c->display_usage) {
		d_printf(  "%s\n"
			   "net printing migrate <file.tdb>\n"
			   "    %s\n",
			 _("Usage:"),
			 _("Migrate tdb printing files to new storage"));
		return 0;
	}

	return run_rpc_command(c,
			       NULL,
			       &ndr_table_winreg.syntax_id,
			       0,
			       printing_migrate_internal,
			       argc,
			       argv);
}
示例#13
0
static int rpc_rights_revoke( int argc, const char **argv )
{
	return run_rpc_command( NULL, PI_LSARPC, 0, 
		rpc_rights_revoke_internal, argc, argv );
}
示例#14
0
static int rpc_service_status( int argc, const char **argv )
{
	return run_rpc_command( NULL, PI_SVCCTL, 0, 
		rpc_service_status_internal, argc, argv );
}
示例#15
0
static int net_dom_unjoin(struct net_context *c, int argc, const char **argv)
{
	const char *server_name = NULL;
	const char *account = NULL;
	const char *password = NULL;
	uint32_t unjoin_flags = NETSETUP_ACCT_DELETE |
				NETSETUP_JOIN_DOMAIN |
				NETSETUP_IGNORE_UNSUPPORTED_FLAGS;
	struct cli_state *cli = NULL;
	bool do_reboot = false;
	NTSTATUS ntstatus;
	NET_API_STATUS status;
	int ret = -1;
	int i;

	if (argc < 1 || c->display_usage) {
		return net_dom_usage(c, argc, argv);
	}

	if (c->opt_host) {
		server_name = c->opt_host;
	}

	for (i=0; i<argc; i++) {
		if (strnequal(argv[i], "account", strlen("account"))) {
			account = get_string_param(argv[i]);
			if (!account) {
				return -1;
			}
		}
		if (strnequal(argv[i], "password", strlen("password"))) {
			password = get_string_param(argv[i]);
			if (!password) {
				return -1;
			}
		}
		if (strequal(argv[i], "reboot")) {
			do_reboot = true;
		}
	}

	if (do_reboot) {
		ntstatus = net_make_ipc_connection_ex(c, c->opt_workgroup,
						      server_name, NULL, 0,
						      &cli);
		if (!NT_STATUS_IS_OK(ntstatus)) {
			return -1;
		}
	}

	status = NetUnjoinDomain(server_name, account, password, unjoin_flags);
	if (status != 0) {
		printf("Failed to unjoin domain: %s\n",
			libnetapi_get_error_string(c->netapi_ctx, status));
		goto done;
	}

	if (do_reboot) {
		c->opt_comment = "Shutting down due to a domain membership "
				 "change";
		c->opt_reboot = true;
		c->opt_timeout = 30;

		ret = run_rpc_command(c, cli,
				      &ndr_table_initshutdown.syntax_id,
				      0, rpc_init_shutdown_internals,
				      argc, argv);
		if (ret == 0) {
			goto done;
		}

		ret = run_rpc_command(c, cli, &ndr_table_winreg.syntax_id, 0,
				      rpc_reg_shutdown_internals,
				      argc, argv);
		goto done;
	}

	ret = 0;

 done:
	if (cli) {
		cli_shutdown(cli);
	}

	return ret;
}