2
* Unix SMB/CIFS implementation.
3
* NetUserModalsSet query
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
uint8_t *buffer = NULL;
38
uint32_t parm_err = 0;
40
struct USER_MODALS_INFO_0 u0;
41
struct USER_MODALS_INFO_1 u1;
42
struct USER_MODALS_INFO_2 u2;
43
struct USER_MODALS_INFO_3 u3;
44
struct USER_MODALS_INFO_1001 u1001;
45
struct USER_MODALS_INFO_1002 u1002;
46
struct USER_MODALS_INFO_1003 u1003;
47
struct USER_MODALS_INFO_1004 u1004;
48
struct USER_MODALS_INFO_1005 u1005;
49
struct USER_MODALS_INFO_1006 u1006;
50
struct USER_MODALS_INFO_1007 u1007;
55
struct poptOption long_options[] = {
57
POPT_COMMON_LIBNETAPI_EXAMPLES
61
status = libnetapi_init(&ctx);
66
pc = poptGetContext("user_modalsset", argc, argv, long_options, 0);
68
poptSetOtherOptionHelp(pc, "hostname level value");
69
while((opt = poptGetNextOpt(pc)) != -1) {
72
if (!poptPeekArg(pc)) {
73
poptPrintHelp(pc, stderr, 0);
76
hostname = poptGetArg(pc);
78
if (poptPeekArg(pc)) {
79
level = atoi(poptGetArg(pc));
82
if (poptPeekArg(pc)) {
83
value = atoi(poptGetArg(pc));
88
u0.usrmod0_min_passwd_len = 0;
89
u0.usrmod0_max_passwd_age = (86400 * 30); /* once a month */
90
u0.usrmod0_min_passwd_age = 0;
91
u0.usrmod0_force_logoff = TIMEQ_FOREVER;
92
u0.usrmod0_password_hist_len = 0;
93
buffer = (uint8_t *)&u0;
100
u1001.usrmod1001_min_passwd_len = 0;
101
buffer = (uint8_t *)&u1001;
104
u1002.usrmod1002_max_passwd_age = 0;
105
buffer = (uint8_t *)&u1002;
108
u1003.usrmod1003_min_passwd_age = (86400 * 30); /* once a month */
109
buffer = (uint8_t *)&u1003;
112
u1004.usrmod1004_force_logoff = TIMEQ_FOREVER;
113
buffer = (uint8_t *)&u1004;
116
u1005.usrmod1005_password_hist_len = 0;
117
buffer = (uint8_t *)&u1005;
125
/* NetUserModalsSet */
127
status = NetUserModalsSet(hostname,
132
printf("NetUserModalsSet failed with: %s\n",
133
libnetapi_get_error_string(ctx, status));