mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[NET]
- Convert error messages to resource strings. - ACCOUNTS: Add some padding to display strings. - USER: Support interactive password input. svn path=/trunk/; revision=65323
This commit is contained in:
parent
3c80eb5dc2
commit
34353069cc
9 changed files with 145 additions and 24 deletions
|
@ -48,7 +48,7 @@ cmdAccounts(
|
|||
|
||||
if (_wcsicmp(argv[i], L"/domain") == 0)
|
||||
{
|
||||
PrintToConsole(L"The /DOMAIN option is not supported yet!\n");
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
|
||||
#if 0
|
||||
Domain = TRUE;
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ cmdAccounts(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /FORCELOGOFF option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/FORCELOGOFF");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ cmdAccounts(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /MINPWLEN option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWLEN");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ cmdAccounts(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /MAXPWAGE option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MAXPWLEN");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ cmdAccounts(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /MINPWAGE option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/MINPWAGE");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ cmdAccounts(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /UNIQUEPW option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/UNIQUEPW");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -168,32 +168,32 @@ cmdAccounts(
|
|||
|
||||
RtlGetNtProductType(&ProductType);
|
||||
|
||||
PrintToConsole(L"Force logoff after: ");
|
||||
PrintToConsole(L"Force logoff after: ");
|
||||
if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
|
||||
PrintToConsole(L"Never\n");
|
||||
else
|
||||
PrintToConsole(L"%lu seconds\n", Info0->usrmod0_force_logoff);
|
||||
|
||||
PrintToConsole(L"Minimum password age (in days): %lu\n", Info0->usrmod0_min_passwd_age / 86400);
|
||||
PrintToConsole(L"Maximum password age (in days): %lu\n", Info0->usrmod0_max_passwd_age / 86400);
|
||||
PrintToConsole(L"Minimum password length: %lu\n", Info0->usrmod0_min_passwd_len);
|
||||
PrintToConsole(L"Minimum password age (in days): %lu\n", Info0->usrmod0_min_passwd_age / 86400);
|
||||
PrintToConsole(L"Maximum password age (in days): %lu\n", Info0->usrmod0_max_passwd_age / 86400);
|
||||
PrintToConsole(L"Minimum password length: %lu\n", Info0->usrmod0_min_passwd_len);
|
||||
|
||||
PrintToConsole(L"Password history length: ");
|
||||
PrintToConsole(L"Password history length: ");
|
||||
if (Info0->usrmod0_password_hist_len == 0)
|
||||
PrintToConsole(L"None\n");
|
||||
else
|
||||
PrintToConsole(L"%lu\n", Info0->usrmod0_password_hist_len);
|
||||
|
||||
PrintToConsole(L"Lockout threshold: ");
|
||||
PrintToConsole(L"Lockout threshold: ");
|
||||
if (Info3->usrmod3_lockout_threshold == 0)
|
||||
PrintToConsole(L"Never\n");
|
||||
else
|
||||
PrintToConsole(L"%lu\n", Info3->usrmod3_lockout_threshold);
|
||||
|
||||
PrintToConsole(L"Lockout duration (in minutes): %lu\n", Info3->usrmod3_lockout_duration / 60);
|
||||
PrintToConsole(L"Lockout observation window (in minutes): %lu\n", Info3->usrmod3_lockout_observation_window / 60);
|
||||
PrintToConsole(L"Lockout duration (in minutes): %lu\n", Info3->usrmod3_lockout_duration / 60);
|
||||
PrintToConsole(L"Lockout observation window (in minutes): %lu\n", Info3->usrmod3_lockout_observation_window / 60);
|
||||
|
||||
PrintToConsole(L"Computer role: ");
|
||||
PrintToConsole(L"Computer role: ");
|
||||
|
||||
if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
|
||||
{
|
||||
|
|
|
@ -248,7 +248,7 @@ cmdLocalGroup(
|
|||
}
|
||||
else if (_wcsicmp(argv[i], L"/domain") == 0)
|
||||
{
|
||||
printf("The /DOMAIN option is not supported yet!\n");
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
|
||||
#if 0
|
||||
bDomain = TRUE;
|
||||
#endif
|
||||
|
|
|
@ -267,6 +267,47 @@ done:
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
ReadPassword(
|
||||
LPWSTR *lpPassword,
|
||||
LPBOOL lpAllocated)
|
||||
{
|
||||
WCHAR szPassword1[PWLEN + 1];
|
||||
WCHAR szPassword2[PWLEN + 1];
|
||||
LPWSTR ptr;
|
||||
|
||||
*lpAllocated = FALSE;
|
||||
|
||||
printf("Enter the password for user xxx: ");
|
||||
ReadFromConsole(szPassword1, PWLEN + 1, FALSE);
|
||||
printf("\n");
|
||||
|
||||
printf("Enter the password again: ");
|
||||
ReadFromConsole(szPassword2, PWLEN + 1, FALSE);
|
||||
printf("\n");
|
||||
|
||||
if (wcslen(szPassword1) == wcslen(szPassword2) &&
|
||||
wcscmp(szPassword1, szPassword2) == 0)
|
||||
{
|
||||
ptr = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(wcslen(szPassword1) + 1) * sizeof(WCHAR));
|
||||
if (ptr != NULL)
|
||||
{
|
||||
wcscpy(ptr, szPassword1);
|
||||
*lpPassword = ptr;
|
||||
*lpAllocated = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("The passwords do not match!");
|
||||
*lpPassword = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INT
|
||||
cmdUser(
|
||||
INT argc,
|
||||
|
@ -286,6 +327,7 @@ cmdUser(
|
|||
LPWSTR p;
|
||||
LPWSTR endptr;
|
||||
DWORD value;
|
||||
BOOL bPasswordAllocated = FALSE;
|
||||
NET_API_STATUS Status;
|
||||
|
||||
if (argc == 2)
|
||||
|
@ -305,14 +347,14 @@ cmdUser(
|
|||
if (argv[i][0] != L'/')
|
||||
{
|
||||
lpUserName = argv[i];
|
||||
printf("User: %S\n", lpUserName);
|
||||
// printf("User: %S\n", lpUserName);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (argv[i][0] != L'/')
|
||||
{
|
||||
lpPassword = argv[i];
|
||||
printf("Password: %S\n", lpPassword);
|
||||
// printf("Password: %S\n", lpPassword);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -333,7 +375,7 @@ cmdUser(
|
|||
}
|
||||
else if (_wcsicmp(argv[j], L"/domain") == 0)
|
||||
{
|
||||
printf("The /DOMAIN option is not supported yet!\n");
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
|
||||
#if 0
|
||||
bDomain = TRUE;
|
||||
#endif
|
||||
|
@ -346,6 +388,13 @@ cmdUser(
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* Interactive password input */
|
||||
if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
|
||||
{
|
||||
ReadPassword(&lpPassword,
|
||||
&bPasswordAllocated);
|
||||
}
|
||||
|
||||
if (!bAdd && !bDelete)
|
||||
{
|
||||
/* Modify the user */
|
||||
|
@ -387,7 +436,7 @@ cmdUser(
|
|||
}
|
||||
else
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /ACTIVE option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/ACTIVE");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -402,7 +451,7 @@ cmdUser(
|
|||
value = wcstoul(p, &endptr, 10);
|
||||
if (*endptr != 0)
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /COUNTRYCODE option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/COUNTRYCODE");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -413,6 +462,16 @@ cmdUser(
|
|||
}
|
||||
else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
|
||||
{
|
||||
p = &argv[i][9];
|
||||
if (_wcsicmp(p, L"never") == 0)
|
||||
{
|
||||
pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Parse the date */
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/EXPIRES");
|
||||
}
|
||||
}
|
||||
else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
|
||||
{
|
||||
|
@ -435,7 +494,7 @@ cmdUser(
|
|||
}
|
||||
else
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /PASSWORDCHG option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDCHG");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -453,7 +512,7 @@ cmdUser(
|
|||
}
|
||||
else
|
||||
{
|
||||
PrintToConsole(L"You entered an invalid value for the /PASSWORDREQ option.\n");
|
||||
PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE, L"/PASSWORDREQ");
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
|
@ -468,6 +527,8 @@ cmdUser(
|
|||
}
|
||||
else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
|
||||
{
|
||||
/* FIXME */
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/TIMES");
|
||||
}
|
||||
else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
|
||||
{
|
||||
|
@ -475,6 +536,8 @@ cmdUser(
|
|||
}
|
||||
else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
|
||||
{
|
||||
/* FIXME */
|
||||
PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/WORKSTATIONS");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,6 +569,9 @@ cmdUser(
|
|||
}
|
||||
|
||||
done:
|
||||
if (bPasswordAllocated == TRUE && lpPassword != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, lpPassword);
|
||||
|
||||
if (!bAdd && !bDelete && pUserInfo != NULL)
|
||||
NetApiBufferFree(pUserInfo);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
IDS_SESSION_HELP "SESSION\n..."
|
||||
IDS_SHARE_SYNTAX "Usage:\nNET SHARE ..."
|
||||
IDS_SHARE_HELP "SHARE\n..."
|
||||
IDS_START_SYNTAX "Usage:\nNET START ..."
|
||||
IDS_START_SYNTAX "Usage:\nNET START <Service name>"
|
||||
IDS_START_HELP "START\n..."
|
||||
IDS_STATISTICS_SYNTAX "Usage:\nNET STATISTICS ..."
|
||||
IDS_STATISTICS_HELP "STATISTICS\n..."
|
||||
|
@ -64,4 +64,7 @@ BEGIN
|
|||
IDS_NET_SYNTAX "Usage:\nNET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |\n\
|
||||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
|
||||
IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s option.\n"
|
||||
END
|
||||
|
|
|
@ -70,4 +70,7 @@ BEGIN
|
|||
IDS_NET_SYNTAX "Utilizare:\nNET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |\n\
|
||||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
|
||||
IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s option.\n"
|
||||
END
|
||||
|
|
|
@ -66,4 +66,7 @@ BEGIN
|
|||
IDS_NET_SYNTAX "Использование:\nNET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |\n\
|
||||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
|
||||
IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s option.\n"
|
||||
END
|
||||
|
|
|
@ -118,6 +118,43 @@ WriteToConsole(
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
ReadFromConsole(
|
||||
LPWSTR lpInput,
|
||||
DWORD dwLength,
|
||||
BOOL bEcho)
|
||||
{
|
||||
DWORD dwOldMode;
|
||||
DWORD dwRead = 0;
|
||||
HANDLE hFile;
|
||||
LPWSTR p;
|
||||
PCHAR pBuf;
|
||||
|
||||
pBuf = HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
|
||||
ZeroMemory(lpInput, dwLength * sizeof(WCHAR));
|
||||
hFile = GetStdHandle(STD_INPUT_HANDLE);
|
||||
GetConsoleMode(hFile, &dwOldMode);
|
||||
|
||||
SetConsoleMode(hFile, ENABLE_LINE_INPUT | (bEcho ? ENABLE_ECHO_INPUT : 0));
|
||||
|
||||
ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
|
||||
|
||||
MultiByteToWideChar(CP_OEMCP, 0, pBuf, dwRead, lpInput, dwLength - 1);
|
||||
HeapFree(GetProcessHeap(), 0, pBuf);
|
||||
|
||||
for (p = lpInput; *p; p++)
|
||||
{
|
||||
if (*p == L'\x0d')
|
||||
{
|
||||
*p = L'\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetConsoleMode(hFile, dwOldMode);
|
||||
}
|
||||
|
||||
|
||||
int wmain(int argc, WCHAR **argv)
|
||||
{
|
||||
PCOMMAND cmdptr;
|
||||
|
|
|
@ -39,6 +39,12 @@ VOID
|
|||
WriteToConsole(
|
||||
LPWSTR lpString);
|
||||
|
||||
VOID
|
||||
ReadFromConsole(
|
||||
LPWSTR lpInput,
|
||||
DWORD dwLength,
|
||||
BOOL bEcho);
|
||||
|
||||
VOID help(VOID);
|
||||
INT unimplemented(INT argc, WCHAR **argv);
|
||||
|
||||
|
|
|
@ -44,3 +44,6 @@
|
|||
#define IDS_VIEW_HELP 141
|
||||
#define IDS_HELP_SYNTAX 142
|
||||
#define IDS_NET_SYNTAX 143
|
||||
|
||||
#define IDS_ERROR_OPTION_NOT_SUPPORTED 500
|
||||
#define IDS_ERROR_INVALID_OPTION_VALUE 501
|
||||
|
|
Loading…
Reference in a new issue