ReactOS  0.4.12-dev-685-gf36cbf7
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 */
40  PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
41  return 0;
42  }
43 
44  if (_wcsicmp(argv[i], L"/help") == 0)
45  {
46  /* Print full help text*/
48  PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
49  PrintNetMessage(MSG_ACCOUNTS_HELP);
51  return 0;
52  }
53 
54  if (_wcsicmp(argv[i], L"/domain") == 0)
55  {
57 #if 0
58  Domain = TRUE;
59 #endif
60  }
61  }
62 
63  Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
64  if (Status != NERR_Success)
65  goto done;
66 
67  for (i = 2; i < argc; i++)
68  {
69  if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
70  {
71  p = &argv[i][13];
72  if (wcsicmp(p, L"no"))
73  {
75  Modified = TRUE;
76  }
77  else
78  {
79  value = wcstoul(p, &endptr, 10);
80  if (*endptr != 0)
81  {
83  result = 1;
84  goto done;
85  }
86 
87  Info0->usrmod0_force_logoff = value * 60;
88  Modified = TRUE;
89  }
90  }
91  else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
92  {
93  p = &argv[i][10];
94  value = wcstoul(p, &endptr, 10);
95  if (*endptr != 0)
96  {
98  result = 1;
99  goto done;
100  }
101 
102  Info0->usrmod0_min_passwd_len = value;
103  Modified = TRUE;
104  }
105  else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
106  {
107  p = &argv[i][10];
108 
109  if (wcsicmp(p, L"unlimited"))
110  {
112  Modified = TRUE;
113  }
114  else
115  {
116  value = wcstoul(p, &endptr, 10);
117  if (*endptr != 0)
118  {
120  result = 1;
121  goto done;
122  }
123 
124  Info0->usrmod0_max_passwd_age = value * 86400;
125  Modified = TRUE;
126  }
127  }
128  else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
129  {
130  p = &argv[i][10];
131  value = wcstoul(p, &endptr, 10);
132  if (*endptr != 0)
133  {
135  result = 1;
136  goto done;
137  }
138 
139  Info0->usrmod0_min_passwd_age = value * 86400;
140  Modified = TRUE;
141  }
142  else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
143  {
144  p = &argv[i][10];
145  value = wcstoul(p, &endptr, 10);
146  if (*endptr != 0)
147  {
149  result = 1;
150  goto done;
151  }
152 
154  Modified = TRUE;
155  }
156  }
157 
158  if (Modified == TRUE)
159  {
160  Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
161  if (Status != NERR_Success)
162  goto done;
163  }
164  else
165  {
166  Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
167  if (Status != NERR_Success)
168  goto done;
169 
170  Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
171  if (Status != NERR_Success)
172  goto done;
173 
174  RtlGetNtProductType(&ProductType);
175 
177  if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
179  else
181  ConPuts(StdOut, L"\n");
182 
184  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
185 
187  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
188 
190  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
191 
193  if (Info0->usrmod0_password_hist_len == 0)
195  else
197  ConPuts(StdOut, L"\n");
198 
200  if (Info3->usrmod3_lockout_threshold == 0)
202  else
204  ConPuts(StdOut, L"\n");
205 
207  ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
208 
211 
213  if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
214  {
215  if (ProductType == NtProductLanManNt)
216  {
218  }
219  else if (ProductType == NtProductServer)
220  {
222  }
223  else
224  {
226  }
227  }
228  else
229  {
231  }
232  ConPuts(StdOut, L"\n");
233  }
234 
235 done:
236  if (Info3 != NULL)
237  NetApiBufferFree(Info3);
238 
239  if (Info1 != NULL)
240  NetApiBufferFree(Info1);
241 
242  if (Info0 != NULL)
243  NetApiBufferFree(Info0);
244 
245  return result;
246 }
static int argc
Definition: ServiceArgs.c:12
#define IDS_ACCOUNTS_LOGOFF_SECONDS
Definition: resource.h:4
#define IDS_ACCOUNTS_PRIMARY_SERVER
Definition: resource.h:13
#define TRUE
Definition: types.h:120
#define IDS_ACCOUNTS_WORKSTATION
Definition: resource.h:16
#define IDS_ACCOUNTS_MIN_PW_LENGTH
Definition: resource.h:7
#define IDS_ACCOUNTS_MAX_PW_AGE
Definition: resource.h:6
#define IDS_ACCOUNTS_LOCKOUT_WINDOW
Definition: resource.h:11
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:122
#define IDS_ACCOUNTS_STANDALONE_SERVER
Definition: resource.h:15
DWORD usrmod3_lockout_duration
Definition: lmaccess.h:448
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:149
#define IDS_ACCOUNTS_LOCKOUT_DURATION
Definition: resource.h:10
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
DWORD usrmod0_min_passwd_len
Definition: lmaccess.h:433
#define IDS_ACCOUNTS_BACKUP_SERVER
Definition: resource.h:14
#define IDS_GENERIC_NEVER
Definition: resource.h:113
BOOLEAN NTAPI RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDS_GENERIC_SYNTAX
Definition: resource.h:118
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:119
smooth NULL
Definition: ftsmooth.c:416
#define IDS_ACCOUNTS_PW_HIST_LENGTH
Definition: resource.h:8
#define IDS_ACCOUNTS_FORCE_LOGOFF
Definition: resource.h:3
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:12
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
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:121
static const WCHAR L[]
Definition: oid.c:1250
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:52
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: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:114
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304
_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_MIN_PW_AGE
Definition: resource.h:5