[NET][MC] Move remaining generic strings from net.exe to netmsg.dll.
[reactos.git] / base / applications / network / net / cmdAccounts.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdAccounts.c
5 * PURPOSE:
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 #include "net.h"
11
12 INT
13 cmdAccounts(
14 INT argc,
15 WCHAR **argv)
16 {
17 PUSER_MODALS_INFO_0 Info0 = NULL;
18 PUSER_MODALS_INFO_1 Info1 = NULL;
19 PUSER_MODALS_INFO_3 Info3 = NULL;
20 NT_PRODUCT_TYPE ProductType;
21 LPWSTR p;
22 LPWSTR endptr;
23 DWORD ParamErr;
24 ULONG value;
25 INT i;
26 BOOL Modified = FALSE;
27 #if 0
28 BOOL Domain = FALSE;
29 #endif
30 INT nPaddedLength = 58;
31 NET_API_STATUS Status;
32 INT result = 0;
33
34 for (i = 2; i < argc; i++)
35 {
36 if (_wcsicmp(argv[i], L"help") == 0)
37 {
38 /* Print short syntax help */
39 PrintMessageString(4381);
40 ConPuts(StdOut, L"\n");
41 PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
42 return 0;
43 }
44
45 if (_wcsicmp(argv[i], L"/help") == 0)
46 {
47 /* Print full help text*/
48 PrintMessageString(4381);
49 ConPuts(StdOut, L"\n");
50 PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
51 PrintNetMessage(MSG_ACCOUNTS_HELP);
52 return 0;
53 }
54
55 if (_wcsicmp(argv[i], L"/domain") == 0)
56 {
57 ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
58 #if 0
59 Domain = TRUE;
60 #endif
61 }
62 }
63
64 Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
65 if (Status != NERR_Success)
66 goto done;
67
68 for (i = 2; i < argc; i++)
69 {
70 if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
71 {
72 p = &argv[i][13];
73 if (wcsicmp(p, L"no") == 0)
74 {
75 Info0->usrmod0_force_logoff = TIMEQ_FOREVER;
76 Modified = TRUE;
77 }
78 else
79 {
80 value = wcstoul(p, &endptr, 10);
81 if (*endptr != 0)
82 {
83 PrintMessageStringV(3952, L"/FORCELOGOFF");
84 result = 1;
85 goto done;
86 }
87
88 Info0->usrmod0_force_logoff = value * 60;
89 Modified = TRUE;
90 }
91 }
92 else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
93 {
94 p = &argv[i][10];
95 value = wcstoul(p, &endptr, 10);
96 if (*endptr != 0)
97 {
98 PrintMessageStringV(3952, L"/MINPWLEN");
99 result = 1;
100 goto done;
101 }
102
103 Info0->usrmod0_min_passwd_len = value;
104 Modified = TRUE;
105 }
106 else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
107 {
108 p = &argv[i][10];
109
110 if (wcsicmp(p, L"unlimited"))
111 {
112 Info0->usrmod0_max_passwd_age = ULONG_MAX;
113 Modified = TRUE;
114 }
115 else
116 {
117 value = wcstoul(p, &endptr, 10);
118 if (*endptr != 0)
119 {
120 PrintMessageStringV(3952, L"/MAXPWLEN");
121 result = 1;
122 goto done;
123 }
124
125 Info0->usrmod0_max_passwd_age = value * 86400;
126 Modified = TRUE;
127 }
128 }
129 else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
130 {
131 p = &argv[i][10];
132 value = wcstoul(p, &endptr, 10);
133 if (*endptr != 0)
134 {
135 PrintMessageStringV(3952, L"/MINPWAGE");
136 result = 1;
137 goto done;
138 }
139
140 Info0->usrmod0_min_passwd_age = value * 86400;
141 Modified = TRUE;
142 }
143 else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
144 {
145 p = &argv[i][10];
146 value = wcstoul(p, &endptr, 10);
147 if (*endptr != 0)
148 {
149 PrintMessageStringV(3952, L"/UNIQUEPW");
150 result = 1;
151 goto done;
152 }
153
154 Info0->usrmod0_password_hist_len = value;
155 Modified = TRUE;
156 }
157 }
158
159 if (Modified == TRUE)
160 {
161 Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
162 if (Status != NERR_Success)
163 goto done;
164 }
165 else
166 {
167 Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
168 if (Status != NERR_Success)
169 goto done;
170
171 Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
172 if (Status != NERR_Success)
173 goto done;
174
175 RtlGetNtProductType(&ProductType);
176
177 PrintPaddedResourceString(IDS_ACCOUNTS_FORCE_LOGOFF, nPaddedLength);
178 if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
179 PrintMessageString(4305);
180 else
181 ConResPrintf(StdOut, IDS_ACCOUNTS_LOGOFF_SECONDS, Info0->usrmod0_force_logoff);
182 ConPuts(StdOut, L"\n");
183
184 PrintPaddedMessageString(4572, nPaddedLength);
185 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
186
187 PrintPaddedMessageString(4573, nPaddedLength);
188 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
189
190 PrintPaddedMessageString(4574, nPaddedLength);
191 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
192
193 PrintPaddedMessageString(4575, nPaddedLength);
194 if (Info0->usrmod0_password_hist_len == 0)
195 PrintMessageString(4303);
196 else
197 ConPrintf(StdOut, L"%lu", Info0->usrmod0_password_hist_len);
198 ConPuts(StdOut, L"\n");
199
200 PrintPaddedMessageString(4578, nPaddedLength);
201 if (Info3->usrmod3_lockout_threshold == 0)
202 PrintMessageString(4305);
203 else
204 ConPrintf(StdOut, L"%lu", Info3->usrmod3_lockout_threshold);
205 ConPuts(StdOut, L"\n");
206
207 PrintPaddedMessageString(4579, nPaddedLength);
208 ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
209
210 PrintPaddedMessageString(4580, nPaddedLength);
211 ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_observation_window / 60);
212
213 PrintPaddedMessageString(4576, nPaddedLength);
214 if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
215 {
216 if (ProductType == NtProductLanManNt)
217 {
218 ConResPuts(StdOut, IDS_ACCOUNTS_PRIMARY_SERVER);
219 }
220 else if (ProductType == NtProductServer)
221 {
222 ConResPuts(StdOut, IDS_ACCOUNTS_STANDALONE_SERVER);
223 }
224 else
225 {
226 ConResPuts(StdOut, IDS_ACCOUNTS_WORKSTATION);
227 }
228 }
229 else
230 {
231 ConResPuts(StdOut, IDS_ACCOUNTS_BACKUP_SERVER);
232 }
233 ConPuts(StdOut, L"\n");
234 }
235
236 done:
237 if (Info3 != NULL)
238 NetApiBufferFree(Info3);
239
240 if (Info1 != NULL)
241 NetApiBufferFree(Info1);
242
243 if (Info0 != NULL)
244 NetApiBufferFree(Info0);
245
246 return result;
247 }
248
249 /* EOF */