mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 22:01:43 +00:00
[NET]
USER command: - Replace stings by resource strings. - Add a function to print padded resource strings. - Fix the password input routine. Repeat if the passwords don't match. svn path=/trunk/; revision=65332
This commit is contained in:
parent
5c1937b443
commit
7cfea2fbb6
7 changed files with 196 additions and 42 deletions
|
@ -173,13 +173,25 @@ DisplayUser(LPWSTR lpUserName)
|
|||
if (Status != NERR_Success)
|
||||
goto done;
|
||||
|
||||
PrintToConsole(L"User name %s\n", pUserInfo->usri4_name);
|
||||
PrintToConsole(L"Full name %s\n", pUserInfo->usri4_full_name);
|
||||
PrintToConsole(L"Comment %s\n", pUserInfo->usri4_comment);
|
||||
PrintToConsole(L"User comment %s\n", pUserInfo->usri4_usr_comment);
|
||||
PrintToConsole(L"Country code %03ld ()\n", pUserInfo->usri4_country_code);
|
||||
PrintToConsole(L"Account active %s\n", (pUserInfo->usri4_flags & UF_ACCOUNTDISABLE)? L"No" : ((pUserInfo->usri4_flags & UF_LOCKOUT) ? L"Locked" : L"Yes"));
|
||||
PrintToConsole(L"Account expires ");
|
||||
PrintPaddedResourceString(IDS_USER_NAME);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_name);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_FULL_NAME);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_full_name);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_COMMENT);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_comment);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_USER_COMMENT);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_usr_comment);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_COUNTRY_CODE);
|
||||
PrintToConsole(L"%03ld ()\n", pUserInfo->usri4_country_code);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_ACCOUNT_ACTIVE);
|
||||
PrintToConsole(L"%s\n", (pUserInfo->usri4_flags & UF_ACCOUNTDISABLE)? L"No" : ((pUserInfo->usri4_flags & UF_LOCKOUT) ? L"Locked" : L"Yes"));
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_ACCOUNT_EXPIRES);
|
||||
if (pUserInfo->usri4_acct_expires == TIMEQ_FOREVER)
|
||||
PrintToConsole(L"Never\n");
|
||||
else
|
||||
|
@ -187,40 +199,55 @@ DisplayUser(LPWSTR lpUserName)
|
|||
|
||||
PrintToConsole(L"\n");
|
||||
|
||||
PrintToConsole(L"Password last set ");
|
||||
PrintPaddedResourceString(IDS_USER_PW_LAST_SET);
|
||||
dwLastSet = GetTimeInSeconds() - pUserInfo->usri4_password_age;
|
||||
PrintDateTime(dwLastSet);
|
||||
|
||||
PrintToConsole(L"Password expires ");
|
||||
PrintPaddedResourceString(IDS_USER_PW_EXPIRES);
|
||||
if ((pUserInfo->usri4_flags & UF_DONT_EXPIRE_PASSWD) || pUserModals->usrmod0_max_passwd_age == TIMEQ_FOREVER)
|
||||
PrintToConsole(L"Never\n");
|
||||
else
|
||||
PrintDateTime(dwLastSet + pUserModals->usrmod0_max_passwd_age);
|
||||
|
||||
PrintToConsole(L"Password changeable ");
|
||||
PrintPaddedResourceString(IDS_USER_PW_CHANGEABLE);
|
||||
PrintDateTime(dwLastSet + pUserModals->usrmod0_min_passwd_age);
|
||||
|
||||
PrintToConsole(L"Password required %s\n", (pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? L"No" : L"Yes");
|
||||
PrintToConsole(L"User may change password %s\n", (pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? L"No" : L"Yes");
|
||||
PrintPaddedResourceString(IDS_USER_PW_REQUIRED);
|
||||
PrintToConsole(L"%s\n", (pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? L"No" : L"Yes");
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_CHANGE_PW);
|
||||
PrintToConsole(L"%s\n", (pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? L"No" : L"Yes");
|
||||
|
||||
PrintToConsole(L"\n");
|
||||
PrintToConsole(L"Workstations allowed %s\n", (pUserInfo->usri4_workstations == NULL || wcslen(pUserInfo->usri4_workstations) == 0) ? L"All" : pUserInfo->usri4_workstations);
|
||||
PrintToConsole(L"Logon script %s\n", pUserInfo->usri4_script_path);
|
||||
PrintToConsole(L"User profile %s\n", pUserInfo->usri4_profile);
|
||||
PrintToConsole(L"Home directory %s\n", pUserInfo->usri4_home_dir);
|
||||
PrintToConsole(L"Last logon ");
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_WORKSTATIONS);
|
||||
PrintToConsole(L"%s\n", (pUserInfo->usri4_workstations == NULL || wcslen(pUserInfo->usri4_workstations) == 0) ? L"All" : pUserInfo->usri4_workstations);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_LOGON_SCRIPT);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_script_path);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_PROFILE);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_profile);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_HOME_DIR);
|
||||
PrintToConsole(L"%s\n", pUserInfo->usri4_home_dir);
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_LAST_LOGON);
|
||||
if (pUserInfo->usri4_last_logon == 0)
|
||||
PrintToConsole(L"Never\n");
|
||||
else
|
||||
PrintDateTime(pUserInfo->usri4_last_logon);
|
||||
|
||||
PrintToConsole(L"\n");
|
||||
PrintToConsole(L"Logon hours allowed ");
|
||||
|
||||
PrintPaddedResourceString(IDS_USER_LOGON_HOURS);
|
||||
if (pUserInfo->usri4_logon_hours == NULL)
|
||||
PrintToConsole(L"All\n");
|
||||
|
||||
PrintToConsole(L"\n");
|
||||
|
||||
PrintToConsole(L"\n");
|
||||
PrintToConsole(L"Local group memberships ");
|
||||
PrintPaddedResourceString(IDS_USER_LOCAL_GROUPS);
|
||||
if (dwLocalGroupTotal != 0 && pLocalGroupInfo != NULL)
|
||||
{
|
||||
for (i = 0; i < dwLocalGroupTotal; i++)
|
||||
|
@ -235,7 +262,7 @@ DisplayUser(LPWSTR lpUserName)
|
|||
PrintToConsole(L"\n");
|
||||
}
|
||||
|
||||
PrintToConsole(L"Global group memberships ");
|
||||
PrintPaddedResourceString(IDS_USER_GLOBAL_GROUPS);
|
||||
if (dwGroupTotal != 0 && pGroupInfo != NULL)
|
||||
{
|
||||
for (i = 0; i < dwGroupTotal; i++)
|
||||
|
@ -279,31 +306,35 @@ ReadPassword(
|
|||
|
||||
*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)
|
||||
while (TRUE)
|
||||
{
|
||||
ptr = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(wcslen(szPassword1) + 1) * sizeof(WCHAR));
|
||||
if (ptr != NULL)
|
||||
PrintResourceString(IDS_USER_ENTER_PASSWORD1);
|
||||
ReadFromConsole(szPassword1, PWLEN + 1, FALSE);
|
||||
printf("\n");
|
||||
|
||||
PrintResourceString(IDS_USER_ENTER_PASSWORD2);
|
||||
ReadFromConsole(szPassword2, PWLEN + 1, FALSE);
|
||||
printf("\n");
|
||||
|
||||
if (wcslen(szPassword1) == wcslen(szPassword2) &&
|
||||
wcscmp(szPassword1, szPassword2) == 0)
|
||||
{
|
||||
wcscpy(ptr, szPassword1);
|
||||
*lpPassword = ptr;
|
||||
*lpAllocated = TRUE;
|
||||
ptr = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
(wcslen(szPassword1) + 1) * sizeof(WCHAR));
|
||||
if (ptr != NULL)
|
||||
{
|
||||
wcscpy(ptr, szPassword1);
|
||||
*lpPassword = ptr;
|
||||
*lpAllocated = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintResourceString(IDS_USER_NO_PASSWORD_MATCH);
|
||||
*lpPassword = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("The passwords do not match!");
|
||||
*lpPassword = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,31 @@ BEGIN
|
|||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_USER_NAME "User name"
|
||||
IDS_USER_FULL_NAME "Full name"
|
||||
IDS_USER_COMMENT "Comment"
|
||||
IDS_USER_USER_COMMENT "User comment"
|
||||
IDS_USER_COUNTRY_CODE "Country code"
|
||||
IDS_USER_ACCOUNT_ACTIVE "Account active"
|
||||
IDS_USER_ACCOUNT_EXPIRES "Account expires"
|
||||
IDS_USER_PW_LAST_SET "Password last set"
|
||||
IDS_USER_PW_EXPIRES "Password expires"
|
||||
IDS_USER_PW_CHANGEABLE "Password changeable"
|
||||
IDS_USER_PW_REQUIRED "Password required"
|
||||
IDS_USER_CHANGE_PW "User may change password"
|
||||
IDS_USER_WORKSTATIONS "Workstations allowed"
|
||||
IDS_USER_LOGON_SCRIPT "Logon script"
|
||||
IDS_USER_PROFILE "User profile"
|
||||
IDS_USER_HOME_DIR "Home directory"
|
||||
IDS_USER_LAST_LOGON "Last logon"
|
||||
IDS_USER_LOGON_HOURS "Logon hours allowed"
|
||||
IDS_USER_LOCAL_GROUPS "Local group memberships"
|
||||
IDS_USER_GLOBAL_GROUPS "Global group memberships"
|
||||
|
||||
IDS_USER_ENTER_PASSWORD1 "Enter a new password for the user: "
|
||||
IDS_USER_ENTER_PASSWORD2 "Enter the password again: "
|
||||
IDS_USER_NO_PASSWORD_MATCH "\nThe passwords do not match!\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
|
||||
|
|
|
@ -71,6 +71,31 @@ BEGIN
|
|||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_USER_NAME "User name"
|
||||
IDS_USER_FULL_NAME "Full name"
|
||||
IDS_USER_COMMENT "Comment"
|
||||
IDS_USER_USER_COMMENT "User comment"
|
||||
IDS_USER_COUNTRY_CODE "Country code"
|
||||
IDS_USER_ACCOUNT_ACTIVE "Account active"
|
||||
IDS_USER_ACCOUNT_EXPIRES "Account expires"
|
||||
IDS_USER_PW_LAST_SET "Password last set"
|
||||
IDS_USER_PW_EXPIRES "Password expires"
|
||||
IDS_USER_PW_CHANGEABLE "Password changeable"
|
||||
IDS_USER_PW_REQUIRED "Password required"
|
||||
IDS_USER_CHANGE_PW "User may change password"
|
||||
IDS_USER_WORKSTATIONS "Workstations allowed"
|
||||
IDS_USER_LOGON_SCRIPT "Logon script"
|
||||
IDS_USER_PROFILE "User profile"
|
||||
IDS_USER_HOME_DIR "Home directory"
|
||||
IDS_USER_LAST_LOGON "Last logon"
|
||||
IDS_USER_LOGON_HOURS "Logon hours allowed"
|
||||
IDS_USER_LOCAL_GROUPS "Local group memberships"
|
||||
IDS_USER_GLOBAL_GROUPS "Global group memberships"
|
||||
|
||||
IDS_USER_ENTER_PASSWORD1 "Enter a new password for the user: "
|
||||
IDS_USER_ENTER_PASSWORD2 "Enter the password again: "
|
||||
IDS_USER_NO_PASSWORD_MATCH "\nThe passwords do not match!\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
|
||||
|
|
|
@ -67,6 +67,31 @@ BEGIN
|
|||
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
|
||||
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
|
||||
|
||||
IDS_USER_NAME "User name"
|
||||
IDS_USER_FULL_NAME "Full name"
|
||||
IDS_USER_COMMENT "Comment"
|
||||
IDS_USER_USER_COMMENT "User comment"
|
||||
IDS_USER_COUNTRY_CODE "Country code"
|
||||
IDS_USER_ACCOUNT_ACTIVE "Account active"
|
||||
IDS_USER_ACCOUNT_EXPIRES "Account expires"
|
||||
IDS_USER_PW_LAST_SET "Password last set"
|
||||
IDS_USER_PW_EXPIRES "Password expires"
|
||||
IDS_USER_PW_CHANGEABLE "Password changeable"
|
||||
IDS_USER_PW_REQUIRED "Password required"
|
||||
IDS_USER_CHANGE_PW "User may change password"
|
||||
IDS_USER_WORKSTATIONS "Workstations allowed"
|
||||
IDS_USER_LOGON_SCRIPT "Logon script"
|
||||
IDS_USER_PROFILE "User profile"
|
||||
IDS_USER_HOME_DIR "Home directory"
|
||||
IDS_USER_LAST_LOGON "Last logon"
|
||||
IDS_USER_LOGON_HOURS "Logon hours allowed"
|
||||
IDS_USER_LOCAL_GROUPS "Local group memberships"
|
||||
IDS_USER_GLOBAL_GROUPS "Global group memberships"
|
||||
|
||||
IDS_USER_ENTER_PASSWORD1 "Enter a new password for the user: "
|
||||
IDS_USER_ENTER_PASSWORD2 "Enter the password again: "
|
||||
IDS_USER_NO_PASSWORD_MATCH "\nThe passwords do not match!\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
|
||||
|
|
|
@ -64,6 +64,25 @@ PrintResourceString(
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
PrintPaddedResourceString(
|
||||
INT resID)
|
||||
{
|
||||
WCHAR szMsgBuffer[MAX_BUFFER_SIZE];
|
||||
INT nLength, nPaddedLength = 29, i;
|
||||
|
||||
nLength = LoadStringW(GetModuleHandle(NULL), resID, szMsgBuffer, MAX_BUFFER_SIZE);
|
||||
if (nLength < nPaddedLength)
|
||||
{
|
||||
for (i = nLength; i < nPaddedLength; i++)
|
||||
szMsgBuffer[i] = L' ';
|
||||
szMsgBuffer[nPaddedLength] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
WriteToConsole(szMsgBuffer);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
PrintToConsole(
|
||||
LPWSTR lpFormat,
|
||||
|
|
|
@ -30,6 +30,10 @@ PrintResourceString(
|
|||
INT resID,
|
||||
...);
|
||||
|
||||
VOID
|
||||
PrintPaddedResourceString(
|
||||
INT resID);
|
||||
|
||||
VOID
|
||||
PrintToConsole(
|
||||
LPWSTR lpFormat,
|
||||
|
|
|
@ -45,5 +45,30 @@
|
|||
#define IDS_HELP_SYNTAX 142
|
||||
#define IDS_NET_SYNTAX 143
|
||||
|
||||
#define IDS_USER_NAME 450
|
||||
#define IDS_USER_FULL_NAME 451
|
||||
#define IDS_USER_COMMENT 452
|
||||
#define IDS_USER_USER_COMMENT 453
|
||||
#define IDS_USER_COUNTRY_CODE 454
|
||||
#define IDS_USER_ACCOUNT_ACTIVE 455
|
||||
#define IDS_USER_ACCOUNT_EXPIRES 456
|
||||
#define IDS_USER_PW_LAST_SET 457
|
||||
#define IDS_USER_PW_EXPIRES 458
|
||||
#define IDS_USER_PW_CHANGEABLE 459
|
||||
#define IDS_USER_PW_REQUIRED 460
|
||||
#define IDS_USER_CHANGE_PW 461
|
||||
#define IDS_USER_WORKSTATIONS 462
|
||||
#define IDS_USER_LOGON_SCRIPT 463
|
||||
#define IDS_USER_PROFILE 464
|
||||
#define IDS_USER_HOME_DIR 465
|
||||
#define IDS_USER_LAST_LOGON 466
|
||||
#define IDS_USER_LOGON_HOURS 467
|
||||
#define IDS_USER_LOCAL_GROUPS 468
|
||||
#define IDS_USER_GLOBAL_GROUPS 469
|
||||
|
||||
#define IDS_USER_ENTER_PASSWORD1 490
|
||||
#define IDS_USER_ENTER_PASSWORD2 491
|
||||
#define IDS_USER_NO_PASSWORD_MATCH 492
|
||||
|
||||
#define IDS_ERROR_OPTION_NOT_SUPPORTED 500
|
||||
#define IDS_ERROR_INVALID_OPTION_VALUE 501
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue