2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdAccounts.c
7 * PROGRAMMERS: Eric Kohl
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
;
26 BOOL Modified
= FALSE
;
30 INT nPaddedLength
= 58;
31 NET_API_STATUS Status
;
34 for (i
= 2; i
< argc
; i
++)
36 if (_wcsicmp(argv
[i
], L
"help") == 0)
38 /* Print short syntax help */
39 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
40 ConResPuts(StdOut
, IDS_ACCOUNTS_SYNTAX
);
44 if (_wcsicmp(argv
[i
], L
"/help") == 0)
46 /* Print full help text*/
47 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
48 ConResPuts(StdOut
, IDS_ACCOUNTS_SYNTAX
);
49 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_1
);
50 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_2
);
51 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_3
);
52 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_4
);
53 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_5
);
54 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_6
);
55 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_7
);
56 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_8
);
57 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_9
);
58 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP_10
);
59 ConResPuts(StdOut
, IDS_GENERIC_PAGE
);
63 if (_wcsicmp(argv
[i
], L
"/domain") == 0)
65 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/DOMAIN");
72 Status
= NetUserModalsGet(NULL
, 0, (LPBYTE
*)&Info0
);
73 if (Status
!= NERR_Success
)
76 for (i
= 2; i
< argc
; i
++)
78 if (_wcsnicmp(argv
[i
], L
"/forcelogoff:", 13) == 0)
81 if (wcsicmp(p
, L
"no"))
83 Info0
->usrmod0_force_logoff
= TIMEQ_FOREVER
;
88 value
= wcstoul(p
, &endptr
, 10);
91 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/FORCELOGOFF");
96 Info0
->usrmod0_force_logoff
= value
* 60;
100 else if (_wcsnicmp(argv
[i
], L
"/minpwlen:", 10) == 0)
103 value
= wcstoul(p
, &endptr
, 10);
106 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MINPWLEN");
111 Info0
->usrmod0_min_passwd_len
= value
;
114 else if (_wcsnicmp(argv
[i
], L
"/maxpwage:", 10) == 0)
118 if (wcsicmp(p
, L
"unlimited"))
120 Info0
->usrmod0_max_passwd_age
= ULONG_MAX
;
125 value
= wcstoul(p
, &endptr
, 10);
128 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MAXPWLEN");
133 Info0
->usrmod0_max_passwd_age
= value
* 86400;
137 else if (_wcsnicmp(argv
[i
], L
"/minpwage:", 10) == 0)
140 value
= wcstoul(p
, &endptr
, 10);
143 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MINPWAGE");
148 Info0
->usrmod0_min_passwd_age
= value
* 86400;
151 else if (_wcsnicmp(argv
[i
], L
"/uniquepw:", 10) == 0)
154 value
= wcstoul(p
, &endptr
, 10);
157 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/UNIQUEPW");
162 Info0
->usrmod0_password_hist_len
= value
;
167 if (Modified
== TRUE
)
169 Status
= NetUserModalsSet(NULL
, 0, (LPBYTE
)Info0
, &ParamErr
);
170 if (Status
!= NERR_Success
)
175 Status
= NetUserModalsGet(NULL
, 1, (LPBYTE
*)&Info1
);
176 if (Status
!= NERR_Success
)
179 Status
= NetUserModalsGet(NULL
, 3, (LPBYTE
*)&Info3
);
180 if (Status
!= NERR_Success
)
183 RtlGetNtProductType(&ProductType
);
185 PrintPaddedResourceString(IDS_ACCOUNTS_FORCE_LOGOFF
, nPaddedLength
);
186 if (Info0
->usrmod0_force_logoff
== TIMEQ_FOREVER
)
187 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
189 ConResPrintf(StdOut
, IDS_ACCOUNTS_LOGOFF_SECONDS
, Info0
->usrmod0_force_logoff
);
190 ConPuts(StdOut
, L
"\n");
192 PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_AGE
, nPaddedLength
);
193 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_min_passwd_age
/ 86400);
195 PrintPaddedResourceString(IDS_ACCOUNTS_MAX_PW_AGE
, nPaddedLength
);
196 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_max_passwd_age
/ 86400);
198 PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_LENGTH
, nPaddedLength
);
199 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_min_passwd_len
);
201 PrintPaddedResourceString(IDS_ACCOUNTS_PW_HIST_LENGTH
, nPaddedLength
);
202 if (Info0
->usrmod0_password_hist_len
== 0)
203 ConResPuts(StdOut
, IDS_GENERIC_NONE
);
205 ConPrintf(StdOut
, L
"%lu", Info0
->usrmod0_password_hist_len
);
206 ConPuts(StdOut
, L
"\n");
208 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_THRESHOLD
, nPaddedLength
);
209 if (Info3
->usrmod3_lockout_threshold
== 0)
210 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
212 ConPrintf(StdOut
, L
"%lu", Info3
->usrmod3_lockout_threshold
);
213 ConPuts(StdOut
, L
"\n");
215 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_DURATION
, nPaddedLength
);
216 ConPrintf(StdOut
, L
"%lu\n", Info3
->usrmod3_lockout_duration
/ 60);
218 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_WINDOW
, nPaddedLength
);
219 ConPrintf(StdOut
, L
"%lu\n", Info3
->usrmod3_lockout_observation_window
/ 60);
221 PrintPaddedResourceString(IDS_ACCOUNTS_COMPUTER_ROLE
, nPaddedLength
);
222 if (Info1
->usrmod1_role
== UAS_ROLE_PRIMARY
)
224 if (ProductType
== NtProductLanManNt
)
226 ConResPuts(StdOut
, IDS_ACCOUNTS_PRIMARY_SERVER
);
228 else if (ProductType
== NtProductServer
)
230 ConResPuts(StdOut
, IDS_ACCOUNTS_STANDALONE_SERVER
);
234 ConResPuts(StdOut
, IDS_ACCOUNTS_WORKSTATION
);
239 ConResPuts(StdOut
, IDS_ACCOUNTS_BACKUP_SERVER
);
241 ConPuts(StdOut
, L
"\n");
246 NetApiBufferFree(Info3
);
249 NetApiBufferFree(Info1
);
252 NetApiBufferFree(Info0
);