diff --git a/reactos/base/applications/network/net/cmdAccounts.c b/reactos/base/applications/network/net/cmdAccounts.c index dcd93de724c..63ffc616965 100644 --- a/reactos/base/applications/network/net/cmdAccounts.c +++ b/reactos/base/applications/network/net/cmdAccounts.c @@ -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) { diff --git a/reactos/base/applications/network/net/cmdLocalGroup.c b/reactos/base/applications/network/net/cmdLocalGroup.c index 3cd5af48af3..adce9d1554f 100644 --- a/reactos/base/applications/network/net/cmdLocalGroup.c +++ b/reactos/base/applications/network/net/cmdLocalGroup.c @@ -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 diff --git a/reactos/base/applications/network/net/cmdUser.c b/reactos/base/applications/network/net/cmdUser.c index c9d07c4c89f..0387ff65bb2 100644 --- a/reactos/base/applications/network/net/cmdUser.c +++ b/reactos/base/applications/network/net/cmdUser.c @@ -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); diff --git a/reactos/base/applications/network/net/lang/en-US.rc b/reactos/base/applications/network/net/lang/en-US.rc index d84ca737a50..ae076a1955d 100644 --- a/reactos/base/applications/network/net/lang/en-US.rc +++ b/reactos/base/applications/network/net/lang/en-US.rc @@ -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 " 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 diff --git a/reactos/base/applications/network/net/lang/ro-RO.rc b/reactos/base/applications/network/net/lang/ro-RO.rc index 6ed299ca7e1..ad04716a523 100644 --- a/reactos/base/applications/network/net/lang/ro-RO.rc +++ b/reactos/base/applications/network/net/lang/ro-RO.rc @@ -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 diff --git a/reactos/base/applications/network/net/lang/ru-RU.rc b/reactos/base/applications/network/net/lang/ru-RU.rc index aa5c2da31ed..c073f50de91 100644 --- a/reactos/base/applications/network/net/lang/ru-RU.rc +++ b/reactos/base/applications/network/net/lang/ru-RU.rc @@ -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 diff --git a/reactos/base/applications/network/net/main.c b/reactos/base/applications/network/net/main.c index 1b489cc493c..54ae670aa2b 100644 --- a/reactos/base/applications/network/net/main.c +++ b/reactos/base/applications/network/net/main.c @@ -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; diff --git a/reactos/base/applications/network/net/net.h b/reactos/base/applications/network/net/net.h index 7f1d05924a3..09d6b3deb32 100644 --- a/reactos/base/applications/network/net/net.h +++ b/reactos/base/applications/network/net/net.h @@ -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); diff --git a/reactos/base/applications/network/net/resource.h b/reactos/base/applications/network/net/resource.h index f13e3e1d881..d0de884b93d 100644 --- a/reactos/base/applications/network/net/resource.h +++ b/reactos/base/applications/network/net/resource.h @@ -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