ReactOS  0.4.12-dev-75-g00dd17e
cmdAccounts.c File Reference
#include "net.h"
Include dependency graph for cmdAccounts.c:

Go to the source code of this file.

Functions

INT cmdAccounts (INT argc, WCHAR **argv)
 

Function Documentation

◆ cmdAccounts()

INT cmdAccounts ( INT  argc,
WCHAR **  argv 
)

Definition at line 13 of file cmdAccounts.c.

16 {
17  PUSER_MODALS_INFO_0 Info0 = NULL;
18  PUSER_MODALS_INFO_1 Info1 = NULL;
19  PUSER_MODALS_INFO_3 Info3 = NULL;
20  NT_PRODUCT_TYPE ProductType;
21  LPWSTR p;
22  LPWSTR endptr;
23  DWORD ParamErr;
24  ULONG value;
25  INT i;
26  BOOL Modified = FALSE;
27 #if 0
28  BOOL Domain = FALSE;
29 #endif
30  INT nPaddedLength = 58;
32  INT result = 0;
33 
34  for (i = 2; i < argc; i++)
35  {
36  if (_wcsicmp(argv[i], L"help") == 0)
37  {
38  /* Print short syntax help */
41  return 0;
42  }
43 
44  if (_wcsicmp(argv[i], L"/help") == 0)
45  {
46  /* Print full help text*/
60  return 0;
61  }
62 
63  if (_wcsicmp(argv[i], L"/domain") == 0)
64  {
66 #if 0
67  Domain = TRUE;
68 #endif
69  }
70  }
71 
72  Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
73  if (Status != NERR_Success)
74  goto done;
75 
76  for (i = 2; i < argc; i++)
77  {
78  if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
79  {
80  p = &argv[i][13];
81  if (wcsicmp(p, L"no"))
82  {
84  Modified = TRUE;
85  }
86  else
87  {
88  value = wcstoul(p, &endptr, 10);
89  if (*endptr != 0)
90  {
92  result = 1;
93  goto done;
94  }
95 
96  Info0->usrmod0_force_logoff = value * 60;
97  Modified = TRUE;
98  }
99  }
100  else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
101  {
102  p = &argv[i][10];
103  value = wcstoul(p, &endptr, 10);
104  if (*endptr != 0)
105  {
107  result = 1;
108  goto done;
109  }
110 
111  Info0->usrmod0_min_passwd_len = value;
112  Modified = TRUE;
113  }
114  else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
115  {
116  p = &argv[i][10];
117 
118  if (wcsicmp(p, L"unlimited"))
119  {
121  Modified = TRUE;
122  }
123  else
124  {
125  value = wcstoul(p, &endptr, 10);
126  if (*endptr != 0)
127  {
129  result = 1;
130  goto done;
131  }
132 
133  Info0->usrmod0_max_passwd_age = value * 86400;
134  Modified = TRUE;
135  }
136  }
137  else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
138  {
139  p = &argv[i][10];
140  value = wcstoul(p, &endptr, 10);
141  if (*endptr != 0)
142  {
144  result = 1;
145  goto done;
146  }
147 
148  Info0->usrmod0_min_passwd_age = value * 86400;
149  Modified = TRUE;
150  }
151  else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
152  {
153  p = &argv[i][10];
154  value = wcstoul(p, &endptr, 10);
155  if (*endptr != 0)
156  {
158  result = 1;
159  goto done;
160  }
161 
163  Modified = TRUE;
164  }
165  }
166 
167  if (Modified == TRUE)
168  {
169  Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
170  if (Status != NERR_Success)
171  goto done;
172  }
173  else
174  {
175  Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
176  if (Status != NERR_Success)
177  goto done;
178 
179  Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
180  if (Status != NERR_Success)
181  goto done;
182 
183  RtlGetNtProductType(&ProductType);
184 
186  if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
188  else
190  ConPuts(StdOut, L"\n");
191 
193  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
194 
196  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
197 
199  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
200 
202  if (Info0->usrmod0_password_hist_len == 0)
204  else
206  ConPuts(StdOut, L"\n");
207 
209  if (Info3->usrmod3_lockout_threshold == 0)
211  else
213  ConPuts(StdOut, L"\n");
214 
216  ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
217 
220 
222  if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
223  {
224  if (ProductType == NtProductLanManNt)
225  {
227  }
228  else if (ProductType == NtProductServer)
229  {
231  }
232  else
233  {
235  }
236  }
237  else
238  {
240  }
241  ConPuts(StdOut, L"\n");
242  }
243 
244 done:
245  if (Info3 != NULL)
246  NetApiBufferFree(Info3);
247 
248  if (Info1 != NULL)
249  NetApiBufferFree(Info1);
250 
251  if (Info0 != NULL)
252  NetApiBufferFree(Info0);
253 
254  return result;
255 }
static int argc
Definition: ServiceArgs.c:12
#define IDS_ACCOUNTS_LOGOFF_SECONDS
Definition: resource.h:88
#define IDS_ACCOUNTS_PRIMARY_SERVER
Definition: resource.h:97
#define TRUE
Definition: types.h:120
#define IDS_ACCOUNTS_WORKSTATION
Definition: resource.h:100
#define IDS_ACCOUNTS_MIN_PW_LENGTH
Definition: resource.h:91
#define IDS_ACCOUNTS_MAX_PW_AGE
Definition: resource.h:90
#define IDS_ACCOUNTS_LOCKOUT_WINDOW
Definition: resource.h:95
DWORD usrmod3_lockout_threshold
Definition: lmaccess.h:450
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define IDS_ERROR_INVALID_OPTION_VALUE
Definition: resource.h:206
#define IDS_ACCOUNTS_STANDALONE_SERVER
Definition: resource.h:99
DWORD usrmod3_lockout_duration
Definition: lmaccess.h:448
#define IDS_ACCOUNTS_LOCKOUT_DURATION
Definition: resource.h:94
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define NERR_Success
Definition: lmerr.h:5
DWORD usrmod0_min_passwd_len
Definition: lmaccess.h:433
#define IDS_ACCOUNTS_BACKUP_SERVER
Definition: resource.h:98
#define IDS_GENERIC_NEVER
Definition: resource.h:197
#define IDS_ACCOUNTS_HELP_10
Definition: resource.h:13
BOOLEAN NTAPI RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
#define IDS_ACCOUNTS_HELP_1
Definition: resource.h:4
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD usrmod0_max_passwd_age
Definition: lmaccess.h:434
NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR servername, DWORD level, LPBYTE *bufptr)
Definition: user.c:3261
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_GENERIC_PAGE
Definition: resource.h:203
#define IDS_ACCOUNTS_HELP_3
Definition: resource.h:6
smooth NULL
Definition: ftsmooth.c:416
#define IDS_ACCOUNTS_PW_HIST_LENGTH
Definition: resource.h:92
#define IDS_ACCOUNTS_HELP_2
Definition: resource.h:5
#define IDS_ACCOUNTS_FORCE_LOGOFF
Definition: resource.h:87
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
unsigned int BOOL
Definition: ntddk_ex.h:94
NET_API_STATUS WINAPI NetUserModalsSet(IN LPCWSTR servername, IN DWORD level, IN LPBYTE buf, OUT LPDWORD parm_err)
Definition: user.c:3545
#define UAS_ROLE_PRIMARY
Definition: lmaccess.h:53
#define IDS_ACCOUNTS_COMPUTER_ROLE
Definition: resource.h:96
#define IDS_ACCOUNTS_HELP_5
Definition: resource.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define StdErr
Definition: stream.h:77
DWORD usrmod0_password_hist_len
Definition: lmaccess.h:437
DWORD usrmod0_min_passwd_age
Definition: lmaccess.h:435
#define IDS_ACCOUNTS_HELP_4
Definition: resource.h:7
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:205
static const WCHAR L[]
Definition: oid.c:1087
GLsizei const GLfloat * value
Definition: glext.h:6069
#define wcsicmp
Definition: string.h:1152
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPaddedResourceString(UINT uID, INT nPaddedLength)
Definition: main.c:51
DWORD usrmod0_force_logoff
Definition: lmaccess.h:436
DWORD usrmod3_lockout_observation_window
Definition: lmaccess.h:449
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define IDS_ACCOUNTS_LOCKOUT_THRESHOLD
Definition: resource.h:93
#define IDS_ACCOUNTS_HELP_6
Definition: resource.h:9
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define StdOut
Definition: stream.h:76
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
unsigned int ULONG
Definition: retypes.h:1
#define IDS_GENERIC_NONE
Definition: resource.h:198
#define IDS_ACCOUNTS_HELP_9
Definition: resource.h:12
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDS_ACCOUNTS_SYNTAX
Definition: resource.h:3
GLuint64EXT * result
Definition: glext.h:11304
#define IDS_ACCOUNTS_HELP_7
Definition: resource.h:10
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ULONG_MAX
Definition: limits.h:44
#define IDS_ACCOUNTS_HELP_8
Definition: resource.h:11
#define IDS_ACCOUNTS_MIN_PW_AGE
Definition: resource.h:89