2
* Unix SMB/CIFS implementation.
4
* Copyright (C) Guenther Deschner 2008
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 <sys/types.h>
30
int main(int argc, const char **argv)
32
NET_API_STATUS status;
33
struct libnetapi_ctx *ctx = NULL;
34
const char *hostname = NULL;
35
const char *username = NULL;
37
uint32_t parm_err = 0;
38
uint8_t *buffer = NULL;
39
const char *val = NULL;
41
struct USER_INFO_0 u0;
42
struct USER_INFO_1 u1;
43
struct USER_INFO_2 u2;
44
struct USER_INFO_3 u3;
45
struct USER_INFO_4 u4;
46
struct USER_INFO_21 u21;
47
struct USER_INFO_22 u22;
48
struct USER_INFO_1003 u1003;
49
struct USER_INFO_1005 u1005;
50
struct USER_INFO_1006 u1006;
51
struct USER_INFO_1007 u1007;
52
struct USER_INFO_1008 u1008;
53
struct USER_INFO_1009 u1009;
54
struct USER_INFO_1010 u1010;
55
struct USER_INFO_1011 u1011;
56
struct USER_INFO_1012 u1012;
57
struct USER_INFO_1014 u1014;
58
struct USER_INFO_1017 u1017;
59
struct USER_INFO_1020 u1020;
60
struct USER_INFO_1024 u1024;
61
struct USER_INFO_1051 u1051;
62
struct USER_INFO_1052 u1052;
63
struct USER_INFO_1053 u1053;
68
struct poptOption long_options[] = {
70
POPT_COMMON_LIBNETAPI_EXAMPLES
74
status = libnetapi_init(&ctx);
79
pc = poptGetContext("user_setinfo", argc, argv, long_options, 0);
81
poptSetOtherOptionHelp(pc, "hostname username level");
82
while((opt = poptGetNextOpt(pc)) != -1) {
85
if (!poptPeekArg(pc)) {
86
poptPrintHelp(pc, stderr, 0);
89
hostname = poptGetArg(pc);
91
if (!poptPeekArg(pc)) {
92
poptPrintHelp(pc, stderr, 0);
95
username = poptGetArg(pc);
97
if (!poptPeekArg(pc)) {
98
poptPrintHelp(pc, stderr, 0);
101
level = atoi(poptGetArg(pc));
103
if (!poptPeekArg(pc)) {
104
poptPrintHelp(pc, stderr, 0);
107
val = poptGetArg(pc);
114
buffer = (uint8_t *)&u0;
126
u1003.usri1003_password = val;
127
buffer = (uint8_t *)&u1003;
130
u1005.usri1005_priv = atoi(val);
131
buffer = (uint8_t *)&u1005;
134
u1006.usri1006_home_dir = val;
135
buffer = (uint8_t *)&u1006;
138
u1007.usri1007_comment = val;
139
buffer = (uint8_t *)&u1007;
142
u1008.usri1008_flags = atoi(val);
143
buffer = (uint8_t *)&u1008;
146
u1009.usri1009_script_path = val;
147
buffer = (uint8_t *)&u1009;
150
u1010.usri1010_auth_flags = atoi(val);
151
buffer = (uint8_t *)&u1010;
154
u1011.usri1011_full_name = val;
155
buffer = (uint8_t *)&u1011;
158
u1012.usri1012_usr_comment = val;
159
buffer = (uint8_t *)&u1012;
162
u1014.usri1014_workstations = val;
163
buffer = (uint8_t *)&u1014;
166
u1017.usri1017_acct_expires = atoi(val);
167
buffer = (uint8_t *)&u1017;
172
u1024.usri1024_country_code = atoi(val);
173
buffer = (uint8_t *)&u1024;
176
u1051.usri1051_primary_group_id = atoi(val);
177
buffer = (uint8_t *)&u1051;
180
u1052.usri1052_profile = val;
181
buffer = (uint8_t *)&u1052;
184
u1053.usri1053_home_dir_drive = val;
185
buffer = (uint8_t *)&u1053;
191
status = NetUserSetInfo(hostname,
197
printf("NetUserSetInfo failed with: %s\n",
198
libnetapi_get_error_string(ctx, status));