2 * Unix SMB/CIFS implementation.
3 * NetApi Server Support
4 * Copyright (C) Guenther Deschner 2007
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/>.
22 #include "librpc/gen_ndr/libnetapi.h"
23 #include "lib/netapi/netapi.h"
24 #include "lib/netapi/libnetapi.h"
25 #include "libnet/libnet.h"
27 /****************************************************************
28 ****************************************************************/
30 static WERROR
NetServerGetInfo_l_1005(struct libnetapi_ctx
*ctx
,
33 struct SERVER_INFO_1005 info1005
;
35 info1005
.sv1005_comment
= lp_serverstring();
36 *buffer
= (uint8_t *)talloc_memdup(ctx
, &info1005
, sizeof(info1005
));
44 /****************************************************************
45 ****************************************************************/
47 WERROR
NetServerGetInfo_l(struct libnetapi_ctx
*ctx
,
48 struct NetServerGetInfo
*r
)
50 switch (r
->in
.level
) {
52 return NetServerGetInfo_l_1005(ctx
, r
->out
.buffer
);
54 return WERR_UNKNOWN_LEVEL
;
57 return WERR_UNKNOWN_LEVEL
;
60 /****************************************************************
61 ****************************************************************/
63 WERROR
NetServerGetInfo_r(struct libnetapi_ctx
*ctx
,
64 struct NetServerGetInfo
*r
)
66 struct cli_state
*cli
= NULL
;
67 struct rpc_pipe_client
*pipe_cli
= NULL
;
70 union srvsvc_NetSrvInfo info
;
72 status
= cli_full_connection(&cli
, NULL
, r
->in
.server_name
,
78 CLI_FULL_CONNECTION_USE_KERBEROS
|
79 CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS
,
82 if (!NT_STATUS_IS_OK(status
)) {
83 werr
= ntstatus_to_werror(status
);
87 pipe_cli
= cli_rpc_pipe_open_noauth(cli
, PI_SRVSVC
,
90 werr
= ntstatus_to_werror(status
);
94 status
= rpccli_srvsvc_NetSrvGetInfo(pipe_cli
, ctx
,
99 if (!NT_STATUS_IS_OK(status
)) {
100 werr
= ntstatus_to_werror(status
);
104 *r
->out
.buffer
= talloc_memdup(ctx
, &info
, sizeof(info
));
105 if (!*r
->out
.buffer
) {
118 /****************************************************************
119 ****************************************************************/
121 static WERROR
NetServerSetInfo_l_1005(struct libnetapi_ctx
*ctx
,
122 struct NetServerSetInfo
*r
)
125 struct smbconf_ctx
*conf_ctx
;
126 struct srvsvc_NetSrvInfo1005
*info1005
;
129 *r
->out
.parm_error
= 1005; /* sure here ? */
130 return WERR_INVALID_PARAM
;
133 info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
135 if (!info1005
->comment
) {
136 *r
->out
.parm_error
= 1005;
137 return WERR_INVALID_PARAM
;
140 if (!lp_config_backend_is_registry()) {
141 libnetapi_set_error_string(ctx
,
142 "Configuration manipulation requested but not "
143 "supported by backend");
144 return WERR_NOT_SUPPORTED
;
147 werr
= smbconf_init_reg(ctx
, &conf_ctx
, NULL
);
148 if (!W_ERROR_IS_OK(werr
)) {
152 werr
= smbconf_set_global_parameter(conf_ctx
, "server string",
156 smbconf_shutdown(conf_ctx
);
160 /****************************************************************
161 ****************************************************************/
163 WERROR
NetServerSetInfo_l(struct libnetapi_ctx
*ctx
,
164 struct NetServerSetInfo
*r
)
166 switch (r
->in
.level
) {
168 return NetServerSetInfo_l_1005(ctx
, r
);
170 return WERR_UNKNOWN_LEVEL
;
173 return WERR_UNKNOWN_LEVEL
;
176 /****************************************************************
177 ****************************************************************/
179 WERROR
NetServerSetInfo_r(struct libnetapi_ctx
*ctx
,
180 struct NetServerSetInfo
*r
)
182 struct cli_state
*cli
= NULL
;
183 struct rpc_pipe_client
*pipe_cli
= NULL
;
186 union srvsvc_NetSrvInfo info
;
188 status
= cli_full_connection(&cli
, NULL
, r
->in
.server_name
,
194 CLI_FULL_CONNECTION_USE_KERBEROS
|
195 CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS
,
198 if (!NT_STATUS_IS_OK(status
)) {
199 werr
= ntstatus_to_werror(status
);
203 pipe_cli
= cli_rpc_pipe_open_noauth(cli
, PI_SRVSVC
,
206 werr
= ntstatus_to_werror(status
);
210 switch (r
->in
.level
) {
212 info
.info1005
= (struct srvsvc_NetSrvInfo1005
*)r
->in
.buffer
;
215 werr
= WERR_NOT_SUPPORTED
;
219 status
= rpccli_srvsvc_NetSrvSetInfo(pipe_cli
, ctx
,
225 if (!NT_STATUS_IS_OK(status
)) {
226 werr
= ntstatus_to_werror(status
);