mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[NET]
Implement NET ACCOUNTS command. svn path=/trunk/; revision=63490
This commit is contained in:
parent
68fcd6e10b
commit
0184d61735
4 changed files with 202 additions and 2 deletions
|
@ -3,6 +3,7 @@ add_definitions(-D__USE_W32_SOCKETS)
|
|||
|
||||
list(APPEND SOURCE
|
||||
main.c
|
||||
cmdAccounts.c
|
||||
cmdStart.c
|
||||
cmdStop.c
|
||||
cmdHelpMsg.c
|
||||
|
@ -13,6 +14,6 @@ list(APPEND SOURCE
|
|||
|
||||
add_executable(net ${SOURCE})
|
||||
set_module_type(net win32cui UNICODE)
|
||||
add_importlibs(net advapi32 msvcrt kernel32)
|
||||
add_importlibs(net advapi32 netapi32 msvcrt kernel32 ntdll)
|
||||
add_pch(net net.h SOURCE)
|
||||
add_cd_file(TARGET net DESTINATION reactos/system32 FOR all)
|
||||
|
|
192
reactos/base/applications/network/net/cmdAccounts.c
Normal file
192
reactos/base/applications/network/net/cmdAccounts.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS net command
|
||||
* FILE:
|
||||
* 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;
|
||||
NT_PRODUCT_TYPE ProductType;
|
||||
LPWSTR p, perr;
|
||||
DWORD ParamErr;
|
||||
ULONG value;
|
||||
INT i;
|
||||
BOOL Modified = FALSE;
|
||||
// BOOL Domain = FALSE;
|
||||
NET_API_STATUS Status;
|
||||
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
if (wcsicmp(argv[i], L"help") == 0)
|
||||
{
|
||||
/* Print short syntax help */
|
||||
puts("NET ACCOUNTS [/FORCELOGOFF:{Minutes|NO}] [/MINPWLEN:Length]");
|
||||
puts(" [/MAXPWAGE:{Days|UNLIMITED}] [/MINPWAGE:Days]");
|
||||
puts(" [/UNIQUEPW:Count] [/DOMAIN]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (wcsicmp(argv[i], L"/help") == 0)
|
||||
{
|
||||
/* FIXME: Print long help text*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
if (wcsicmp(argv[i], L"/domain") == 0)
|
||||
{
|
||||
Domain = TRUE;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
|
||||
if (Status != NERR_Success)
|
||||
goto done;
|
||||
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
|
||||
{
|
||||
p = &argv[i][13];
|
||||
if (wcsicmp(p, L"no"))
|
||||
{
|
||||
Info0->usrmod0_force_logoff = TIMEQ_FOREVER;
|
||||
Modified = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = wcstoul(p, &perr, 10);
|
||||
|
||||
Info0->usrmod0_force_logoff = value * 60;
|
||||
Modified = TRUE;
|
||||
}
|
||||
}
|
||||
else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
|
||||
{
|
||||
p = &argv[i][10];
|
||||
value = wcstoul(p, &perr, 10);
|
||||
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
|
||||
{
|
||||
value = wcstoul(p, &perr, 10);
|
||||
|
||||
Info0->usrmod0_max_passwd_age = value * 86400;
|
||||
Modified = TRUE;
|
||||
}
|
||||
}
|
||||
else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
|
||||
{
|
||||
p = &argv[i][10];
|
||||
value = wcstoul(p, &perr, 10);
|
||||
|
||||
Info0->usrmod0_min_passwd_age = value * 86400;
|
||||
Modified = TRUE;
|
||||
}
|
||||
else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
|
||||
{
|
||||
p = &argv[i][10];
|
||||
value = wcstoul(p, &perr, 10);
|
||||
|
||||
Info0->usrmod0_password_hist_len = value;
|
||||
Modified = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Modified == TRUE)
|
||||
{
|
||||
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);
|
||||
|
||||
printf("Force logoff after: ");
|
||||
if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
|
||||
printf("Never\n");
|
||||
else
|
||||
printf("%lu seconds\n", Info0->usrmod0_force_logoff);
|
||||
|
||||
printf("Minimum password age (in days): %lu\n", Info0->usrmod0_min_passwd_age / 86400);
|
||||
printf("Maximum password age (in days): %lu\n", Info0->usrmod0_max_passwd_age / 86400);
|
||||
printf("Minimum password length: %lu\n", Info0->usrmod0_min_passwd_len);
|
||||
|
||||
printf("Password history length: ");
|
||||
if (Info0->usrmod0_password_hist_len == 0)
|
||||
printf("None\n");
|
||||
else
|
||||
printf("%lu\n", Info0->usrmod0_password_hist_len);
|
||||
|
||||
printf("Lockout threshold: %lu\n", Info3->usrmod3_lockout_threshold);
|
||||
printf("Lockout duration (in minutes): %lu\n", Info3->usrmod3_lockout_duration / 60);
|
||||
printf("Lockout observation window (in minutes): %lu\n", Info3->usrmod3_lockout_observation_window / 60);
|
||||
|
||||
printf("Computer role: ");
|
||||
|
||||
if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
|
||||
{
|
||||
if (ProductType == NtProductLanManNt)
|
||||
{
|
||||
printf("Primary server\n");
|
||||
}
|
||||
else if (ProductType == NtProductServer)
|
||||
{
|
||||
printf("Standalone server\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Workstation\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Backup server\n");
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (Info3 != NULL)
|
||||
NetApiBufferFree(Info3);
|
||||
|
||||
if (Info1 != NULL)
|
||||
NetApiBufferFree(Info1);
|
||||
|
||||
if (Info0 != NULL)
|
||||
NetApiBufferFree(Info0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -18,7 +18,7 @@ typedef struct _COMMAND
|
|||
|
||||
COMMAND cmds[] =
|
||||
{
|
||||
{L"accounts", unimplemented},
|
||||
{L"accounts", cmdAccounts},
|
||||
{L"computer", unimplemented},
|
||||
{L"config", unimplemented},
|
||||
{L"continue", cmdContinue},
|
||||
|
|
|
@ -7,16 +7,23 @@
|
|||
#ifndef _NET_PCH_
|
||||
#define _NET_PCH_
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winsvc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <lm.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
VOID help(VOID);
|
||||
INT unimplemented(INT argc, WCHAR **argv);
|
||||
|
||||
INT cmdAccounts(INT argc, WCHAR **argv);
|
||||
INT cmdContinue(INT argc, WCHAR **argv);
|
||||
INT cmdHelp(INT argc, WCHAR **argv);
|
||||
INT cmdHelpMsg(INT argc, WCHAR **argv);
|
||||
|
|
Loading…
Reference in a new issue