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_ACCOUNTS_SYNTAX
);
43 if (_wcsicmp(argv
[i
], L
"/help") == 0)
45 /* Print full help text*/
46 ConResPuts(StdOut
, IDS_ACCOUNTS_HELP
);
50 if (_wcsicmp(argv
[i
], L
"/domain") == 0)
52 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/DOMAIN");
59 Status
= NetUserModalsGet(NULL
, 0, (LPBYTE
*)&Info0
);
60 if (Status
!= NERR_Success
)
63 for (i
= 2; i
< argc
; i
++)
65 if (_wcsnicmp(argv
[i
], L
"/forcelogoff:", 13) == 0)
68 if (wcsicmp(p
, L
"no"))
70 Info0
->usrmod0_force_logoff
= TIMEQ_FOREVER
;
75 value
= wcstoul(p
, &endptr
, 10);
78 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/FORCELOGOFF");
83 Info0
->usrmod0_force_logoff
= value
* 60;
87 else if (_wcsnicmp(argv
[i
], L
"/minpwlen:", 10) == 0)
90 value
= wcstoul(p
, &endptr
, 10);
93 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MINPWLEN");
98 Info0
->usrmod0_min_passwd_len
= value
;
101 else if (_wcsnicmp(argv
[i
], L
"/maxpwage:", 10) == 0)
105 if (wcsicmp(p
, L
"unlimited"))
107 Info0
->usrmod0_max_passwd_age
= ULONG_MAX
;
112 value
= wcstoul(p
, &endptr
, 10);
115 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MAXPWLEN");
120 Info0
->usrmod0_max_passwd_age
= value
* 86400;
124 else if (_wcsnicmp(argv
[i
], L
"/minpwage:", 10) == 0)
127 value
= wcstoul(p
, &endptr
, 10);
130 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/MINPWAGE");
135 Info0
->usrmod0_min_passwd_age
= value
* 86400;
138 else if (_wcsnicmp(argv
[i
], L
"/uniquepw:", 10) == 0)
141 value
= wcstoul(p
, &endptr
, 10);
144 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/UNIQUEPW");
149 Info0
->usrmod0_password_hist_len
= value
;
154 if (Modified
!= FALSE
)
156 Status
= NetUserModalsSet(NULL
, 0, (LPBYTE
)Info0
, &ParamErr
);
157 if (Status
!= NERR_Success
)
162 Status
= NetUserModalsGet(NULL
, 1, (LPBYTE
*)&Info1
);
163 if (Status
!= NERR_Success
)
166 Status
= NetUserModalsGet(NULL
, 3, (LPBYTE
*)&Info3
);
167 if (Status
!= NERR_Success
)
170 RtlGetNtProductType(&ProductType
);
172 PrintPaddedResourceString(IDS_ACCOUNTS_FORCE_LOGOFF
, nPaddedLength
);
173 if (Info0
->usrmod0_force_logoff
== TIMEQ_FOREVER
)
174 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
176 ConResPrintf(StdOut
, IDS_ACCOUNTS_LOGOFF_SECONDS
, Info0
->usrmod0_force_logoff
);
177 ConPuts(StdOut
, L
"\n");
179 PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_AGE
, nPaddedLength
);
180 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_min_passwd_age
/ 86400);
182 PrintPaddedResourceString(IDS_ACCOUNTS_MAX_PW_AGE
, nPaddedLength
);
183 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_max_passwd_age
/ 86400);
185 PrintPaddedResourceString(IDS_ACCOUNTS_MIN_PW_LENGTH
, nPaddedLength
);
186 ConPrintf(StdOut
, L
"%lu\n", Info0
->usrmod0_min_passwd_len
);
188 PrintPaddedResourceString(IDS_ACCOUNTS_PW_HIST_LENGTH
, nPaddedLength
);
189 if (Info0
->usrmod0_password_hist_len
== 0)
190 ConResPuts(StdOut
, IDS_GENERIC_NONE
);
192 ConPrintf(StdOut
, L
"%lu", Info0
->usrmod0_password_hist_len
);
193 ConPuts(StdOut
, L
"\n");
195 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_THRESHOLD
, nPaddedLength
);
196 if (Info3
->usrmod3_lockout_threshold
== 0)
197 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
199 ConPrintf(StdOut
, L
"%lu", Info3
->usrmod3_lockout_threshold
);
200 ConPuts(StdOut
, L
"\n");
202 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_DURATION
, nPaddedLength
);
203 ConPrintf(StdOut
, L
"%lu\n", Info3
->usrmod3_lockout_duration
/ 60);
205 PrintPaddedResourceString(IDS_ACCOUNTS_LOCKOUT_WINDOW
, nPaddedLength
);
206 ConPrintf(StdOut
, L
"%lu\n", Info3
->usrmod3_lockout_observation_window
/ 60);
208 PrintPaddedResourceString(IDS_ACCOUNTS_COMPUTER_ROLE
, nPaddedLength
);
209 if (Info1
->usrmod1_role
== UAS_ROLE_PRIMARY
)
211 if (ProductType
== NtProductLanManNt
)
213 ConResPuts(StdOut
, IDS_ACCOUNTS_PRIMARY_SERVER
);
215 else if (ProductType
== NtProductServer
)
217 ConResPuts(StdOut
, IDS_ACCOUNTS_STANDALONE_SERVER
);
221 ConResPuts(StdOut
, IDS_ACCOUNTS_WORKSTATION
);
226 ConResPuts(StdOut
, IDS_ACCOUNTS_BACKUP_SERVER
);
228 ConPuts(StdOut
, L
"\n");
233 NetApiBufferFree(Info3
);
236 NetApiBufferFree(Info1
);
239 NetApiBufferFree(Info0
);