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 srvsvc_NetSrvInfo1005 info1005;
35 info1005.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,
80 if (!NT_STATUS_IS_OK(status)) {
81 werr = ntstatus_to_werror(status);
85 pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC,
88 werr = ntstatus_to_werror(status);
92 status = rpccli_srvsvc_NetSrvGetInfo(pipe_cli, ctx,
97 if (!NT_STATUS_IS_OK(status)) {
98 werr = ntstatus_to_werror(status);
102 *r->out.buffer = talloc_memdup(ctx, &info, sizeof(info));
103 if (!*r->out.buffer) {
116 /****************************************************************
117 ****************************************************************/
119 static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
120 struct NetServerSetInfo *r)
123 struct smbconf_ctx *conf_ctx;
124 struct srvsvc_NetSrvInfo1005 *info1005;
127 *r->out.parm_error = 1005; /* sure here ? */
128 return WERR_INVALID_PARAM;
131 info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer;
133 if (!info1005->comment) {
134 *r->out.parm_error = 1005;
135 return WERR_INVALID_PARAM;
138 if (!lp_config_backend_is_registry()) {
139 libnetapi_set_error_string(ctx,
140 "Configuration manipulation requested but not "
141 "supported by backend");
142 return WERR_NOT_SUPPORTED;
145 werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
146 if (!W_ERROR_IS_OK(werr)) {
150 werr = smbconf_set_global_parameter(conf_ctx, "server string",
154 smbconf_shutdown(conf_ctx);
158 /****************************************************************
159 ****************************************************************/
161 WERROR NetServerSetInfo_l(struct libnetapi_ctx *ctx,
162 struct NetServerSetInfo *r)
164 switch (r->in.level) {
166 return NetServerSetInfo_l_1005(ctx, r);
168 return WERR_UNKNOWN_LEVEL;
171 return WERR_UNKNOWN_LEVEL;
174 /****************************************************************
175 ****************************************************************/
177 WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
178 struct NetServerSetInfo *r)
180 struct cli_state *cli = NULL;
181 struct rpc_pipe_client *pipe_cli = NULL;
184 union srvsvc_NetSrvInfo info;
186 status = cli_full_connection(&cli, NULL, r->in.server_name,
194 if (!NT_STATUS_IS_OK(status)) {
195 werr = ntstatus_to_werror(status);
199 pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC,
202 werr = ntstatus_to_werror(status);
206 switch (r->in.level) {
208 info.info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer;
211 werr = WERR_NOT_SUPPORTED;
215 status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, ctx,
221 if (!NT_STATUS_IS_OK(status)) {
222 werr = ntstatus_to_werror(status);