libcli/cldap: make use of samba_tevent_context_init()
[Samba/gebeck_regimport.git] / source3 / lib / netapi / shutdown.c
blob78bc2fce6b9ac47d287bda32931aaa43b576d5d6
1 /*
2 * Unix SMB/CIFS implementation.
3 * NetApi Shutdown Support
4 * Copyright (C) Guenther Deschner 2009
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
22 #include "librpc/gen_ndr/libnetapi.h"
23 #include "lib/netapi/netapi.h"
24 #include "lib/netapi/netapi_private.h"
25 #include "lib/netapi/libnetapi.h"
26 #include "../librpc/gen_ndr/ndr_initshutdown_c.h"
27 #include "rpc_client/init_lsa.h"
29 /****************************************************************
30 ****************************************************************/
32 WERROR NetShutdownInit_r(struct libnetapi_ctx *ctx,
33 struct NetShutdownInit *r)
35 WERROR werr;
36 NTSTATUS status;
37 struct lsa_StringLarge message;
38 struct dcerpc_binding_handle *b;
40 werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
41 &ndr_table_initshutdown.syntax_id,
42 &b);
43 if (!W_ERROR_IS_OK(werr)) {
44 goto done;
47 init_lsa_StringLarge(&message, r->in.message);
49 status = dcerpc_initshutdown_Init(b, talloc_tos(),
50 NULL,
51 &message,
52 r->in.timeout,
53 r->in.force_apps,
54 r->in.do_reboot,
55 &werr);
56 if (!NT_STATUS_IS_OK(status)) {
57 werr = ntstatus_to_werror(status);
58 goto done;
61 done:
62 return werr;
65 /****************************************************************
66 ****************************************************************/
68 WERROR NetShutdownInit_l(struct libnetapi_ctx *ctx,
69 struct NetShutdownInit *r)
71 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownInit);
74 /****************************************************************
75 ****************************************************************/
77 WERROR NetShutdownAbort_r(struct libnetapi_ctx *ctx,
78 struct NetShutdownAbort *r)
80 WERROR werr;
81 NTSTATUS status;
82 struct dcerpc_binding_handle *b;
84 werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
85 &ndr_table_initshutdown.syntax_id,
86 &b);
87 if (!W_ERROR_IS_OK(werr)) {
88 goto done;
91 status = dcerpc_initshutdown_Abort(b, talloc_tos(),
92 NULL,
93 &werr);
94 if (!NT_STATUS_IS_OK(status)) {
95 werr = ntstatus_to_werror(status);
96 goto done;
99 done:
100 return werr;
103 /****************************************************************
104 ****************************************************************/
106 WERROR NetShutdownAbort_l(struct libnetapi_ctx *ctx,
107 struct NetShutdownAbort *r)
109 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownAbort);