2014-05-28 08:06:10 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS net command
|
2015-09-09 13:13:35 +00:00
|
|
|
* FILE: base/applications/network/net/cmdAccounts.c
|
2014-05-28 08:06:10 +00:00
|
|
|
* PURPOSE:
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "net.h"
|
|
|
|
|
|
|
|
INT
|
|
|
|
cmdAccounts(
|
|
|
|
INT argc,
|
|
|
|
WCHAR **argv)
|
|
|
|
{
|
|
|
|
PUSER_MODALS_INFO_0 Info0 = NULL;
|
|
|
|
PUSER_MODALS_INFO_1 Info1 = NULL;
|
|
|
|
PUSER_MODALS_INFO_3 Info3 = NULL;
|
2020-07-04 13:16:22 +00:00
|
|
|
NT_PRODUCT_TYPE ProductType = NtProductWinNt;
|
2014-05-31 08:32:54 +00:00
|
|
|
LPWSTR p;
|
|
|
|
LPWSTR endptr;
|
2014-05-28 08:06:10 +00:00
|
|
|
DWORD ParamErr;
|
|
|
|
ULONG value;
|
|
|
|
INT i;
|
|
|
|
BOOL Modified = FALSE;
|
2014-10-19 20:12:19 +00:00
|
|
|
#if 0
|
|
|
|
BOOL Domain = FALSE;
|
|
|
|
#endif
|
2014-11-09 13:39:20 +00:00
|
|
|
INT nPaddedLength = 58;
|
2014-05-28 08:06:10 +00:00
|
|
|
NET_API_STATUS Status;
|
2014-05-31 08:32:54 +00:00
|
|
|
INT result = 0;
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
for (i = 2; i < argc; i++)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
2014-05-31 08:32:54 +00:00
|
|
|
if (_wcsicmp(argv[i], L"help") == 0)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
|
|
|
/* Print short syntax help */
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageString(4381);
|
|
|
|
ConPuts(StdOut, L"\n");
|
2018-12-23 15:47:16 +00:00
|
|
|
PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
|
2014-05-28 08:06:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
if (_wcsicmp(argv[i], L"/help") == 0)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
2014-05-31 08:32:54 +00:00
|
|
|
/* Print full help text*/
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageString(4381);
|
|
|
|
ConPuts(StdOut, L"\n");
|
2018-12-23 15:47:16 +00:00
|
|
|
PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
|
|
|
|
PrintNetMessage(MSG_ACCOUNTS_HELP);
|
2014-05-28 08:06:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
if (_wcsicmp(argv[i], L"/domain") == 0)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
|
2014-10-19 20:12:19 +00:00
|
|
|
#if 0
|
2014-05-28 08:06:10 +00:00
|
|
|
Domain = TRUE;
|
2014-10-19 20:12:19 +00:00
|
|
|
#endif
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
|
|
|
|
if (Status != NERR_Success)
|
|
|
|
goto done;
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
for (i = 2; i < argc; i++)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
|
|
|
if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
|
|
|
|
{
|
|
|
|
p = &argv[i][13];
|
2019-04-09 19:44:03 +00:00
|
|
|
if (wcsicmp(p, L"no") == 0)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
|
|
|
Info0->usrmod0_force_logoff = TIMEQ_FOREVER;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-31 08:32:54 +00:00
|
|
|
value = wcstoul(p, &endptr, 10);
|
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageStringV(3952, L"/FORCELOGOFF");
|
2014-05-31 08:32:54 +00:00
|
|
|
result = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-05-28 08:06:10 +00:00
|
|
|
|
|
|
|
Info0->usrmod0_force_logoff = value * 60;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
|
|
|
|
{
|
|
|
|
p = &argv[i][10];
|
2014-05-31 08:32:54 +00:00
|
|
|
value = wcstoul(p, &endptr, 10);
|
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageStringV(3952, L"/MINPWLEN");
|
2017-09-01 18:00:06 +00:00
|
|
|
result = 1;
|
|
|
|
goto done;
|
2014-05-31 08:32:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 08:06:10 +00:00
|
|
|
Info0->usrmod0_min_passwd_len = value;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
|
|
|
|
{
|
|
|
|
p = &argv[i][10];
|
|
|
|
|
|
|
|
if (wcsicmp(p, L"unlimited"))
|
|
|
|
{
|
|
|
|
Info0->usrmod0_max_passwd_age = ULONG_MAX;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-31 08:32:54 +00:00
|
|
|
value = wcstoul(p, &endptr, 10);
|
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageStringV(3952, L"/MAXPWLEN");
|
2014-05-31 08:32:54 +00:00
|
|
|
result = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-05-28 08:06:10 +00:00
|
|
|
|
|
|
|
Info0->usrmod0_max_passwd_age = value * 86400;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
|
|
|
|
{
|
|
|
|
p = &argv[i][10];
|
2014-05-31 08:32:54 +00:00
|
|
|
value = wcstoul(p, &endptr, 10);
|
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageStringV(3952, L"/MINPWAGE");
|
2014-05-31 08:32:54 +00:00
|
|
|
result = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-05-28 08:06:10 +00:00
|
|
|
|
|
|
|
Info0->usrmod0_min_passwd_age = value * 86400;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
|
|
|
|
{
|
|
|
|
p = &argv[i][10];
|
2014-05-31 08:32:54 +00:00
|
|
|
value = wcstoul(p, &endptr, 10);
|
|
|
|
if (*endptr != 0)
|
|
|
|
{
|
2019-04-09 19:44:03 +00:00
|
|
|
PrintMessageStringV(3952, L"/UNIQUEPW");
|
2014-05-31 08:32:54 +00:00
|
|
|
result = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-05-28 08:06:10 +00:00
|
|
|
|
|
|
|
Info0->usrmod0_password_hist_len = value;
|
|
|
|
Modified = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 20:12:37 +00:00
|
|
|
if (Modified == TRUE)
|
2014-05-28 08:06:10 +00:00
|
|
|
{
|
|
|
|
Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
|
|
|
|
if (Status != NERR_Success)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
|
|
|
|
if (Status != NERR_Success)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
|
|
|
|
if (Status != NERR_Success)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
RtlGetNtProductType(&ProductType);
|
|
|
|
|
2019-05-04 19:08:27 +00:00
|
|
|
PrintPaddedMessageString(4570, nPaddedLength);
|
2014-05-28 08:06:10 +00:00
|
|
|
if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
|
2019-04-08 20:48:06 +00:00
|
|
|
PrintMessageString(4305);
|
2014-05-28 08:06:10 +00:00
|
|
|
else
|
2019-05-04 19:08:27 +00:00
|
|
|
ConPrintf(StdOut, L"%lu", Info0->usrmod0_force_logoff);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPuts(StdOut, L"\n");
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4572, nPaddedLength);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4573, nPaddedLength);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
|
2014-11-09 13:39:20 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4574, nPaddedLength);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
|
2014-11-09 13:39:20 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4575, nPaddedLength);
|
2014-05-28 08:06:10 +00:00
|
|
|
if (Info0->usrmod0_password_hist_len == 0)
|
2019-04-08 20:48:06 +00:00
|
|
|
PrintMessageString(4303);
|
2014-05-28 08:06:10 +00:00
|
|
|
else
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu", Info0->usrmod0_password_hist_len);
|
|
|
|
ConPuts(StdOut, L"\n");
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4578, nPaddedLength);
|
2014-05-31 08:32:54 +00:00
|
|
|
if (Info3->usrmod3_lockout_threshold == 0)
|
2019-04-08 20:48:06 +00:00
|
|
|
PrintMessageString(4305);
|
2014-05-31 08:32:54 +00:00
|
|
|
else
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu", Info3->usrmod3_lockout_threshold);
|
|
|
|
ConPuts(StdOut, L"\n");
|
2014-05-31 08:32:54 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4579, nPaddedLength);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4580, nPaddedLength);
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_observation_window / 60);
|
2014-05-28 08:06:10 +00:00
|
|
|
|
2019-04-05 21:14:07 +00:00
|
|
|
PrintPaddedMessageString(4576, nPaddedLength);
|
2014-05-28 08:06:10 +00:00
|
|
|
if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
|
|
|
|
{
|
|
|
|
if (ProductType == NtProductLanManNt)
|
|
|
|
{
|
2019-05-04 19:08:27 +00:00
|
|
|
PrintMessageString(5070);
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
else if (ProductType == NtProductServer)
|
|
|
|
{
|
2019-05-04 19:08:27 +00:00
|
|
|
PrintMessageString(5073);
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-04 19:08:27 +00:00
|
|
|
PrintMessageString(5072);
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-04 19:08:27 +00:00
|
|
|
PrintMessageString(5071);
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPuts(StdOut, L"\n");
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (Info3 != NULL)
|
|
|
|
NetApiBufferFree(Info3);
|
|
|
|
|
|
|
|
if (Info1 != NULL)
|
|
|
|
NetApiBufferFree(Info1);
|
|
|
|
|
|
|
|
if (Info0 != NULL)
|
|
|
|
NetApiBufferFree(Info0);
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
return result;
|
2014-05-28 08:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|