ReactOS 0.4.16-dev-297-gc569aee
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{
20 NT_PRODUCT_TYPE ProductType = NtProductWinNt;
21 LPWSTR p;
22 LPWSTR endptr;
23 DWORD ParamErr;
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 ConPuts(StdOut, L"\n");
41 PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
42 return 0;
43 }
44
45 if (_wcsicmp(argv[i], L"/help") == 0)
46 {
47 /* Print full help text*/
49 ConPuts(StdOut, L"\n");
50 PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
51 PrintNetMessage(MSG_ACCOUNTS_HELP);
52 return 0;
53 }
54
55 if (_wcsicmp(argv[i], L"/domain") == 0)
56 {
57 ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
58#if 0
59 Domain = TRUE;
60#endif
61 }
62 }
63
64 Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
65 if (Status != NERR_Success)
66 goto done;
67
68 for (i = 2; i < argc; i++)
69 {
70 if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
71 {
72 p = &argv[i][13];
73 if (_wcsicmp(p, L"no") == 0)
74 {
76 Modified = TRUE;
77 }
78 else
79 {
80 value = wcstoul(p, &endptr, 10);
81 if (*endptr != 0)
82 {
83 PrintMessageStringV(3952, L"/FORCELOGOFF");
84 result = 1;
85 goto done;
86 }
87
88 Info0->usrmod0_force_logoff = value * 60;
89 Modified = TRUE;
90 }
91 }
92 else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
93 {
94 p = &argv[i][10];
95 value = wcstoul(p, &endptr, 10);
96 if (*endptr != 0)
97 {
98 PrintMessageStringV(3952, L"/MINPWLEN");
99 result = 1;
100 goto done;
101 }
102
104 Modified = TRUE;
105 }
106 else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
107 {
108 p = &argv[i][10];
109
110 if (_wcsicmp(p, L"unlimited"))
111 {
113 Modified = TRUE;
114 }
115 else
116 {
117 value = wcstoul(p, &endptr, 10);
118 if (*endptr != 0)
119 {
120 PrintMessageStringV(3952, L"/MAXPWLEN");
121 result = 1;
122 goto done;
123 }
124
125 Info0->usrmod0_max_passwd_age = value * 86400;
126 Modified = TRUE;
127 }
128 }
129 else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
130 {
131 p = &argv[i][10];
132 value = wcstoul(p, &endptr, 10);
133 if (*endptr != 0)
134 {
135 PrintMessageStringV(3952, L"/MINPWAGE");
136 result = 1;
137 goto done;
138 }
139
140 Info0->usrmod0_min_passwd_age = value * 86400;
141 Modified = TRUE;
142 }
143 else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
144 {
145 p = &argv[i][10];
146 value = wcstoul(p, &endptr, 10);
147 if (*endptr != 0)
148 {
149 PrintMessageStringV(3952, L"/UNIQUEPW");
150 result = 1;
151 goto done;
152 }
153
155 Modified = TRUE;
156 }
157 }
158
159 if (Modified == TRUE)
160 {
161 Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
162 if (Status != NERR_Success)
163 goto done;
164 }
165 else
166 {
167 Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
168 if (Status != NERR_Success)
169 goto done;
170
171 Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
172 if (Status != NERR_Success)
173 goto done;
174
175 RtlGetNtProductType(&ProductType);
176
177 PrintPaddedMessageString(4570, nPaddedLength);
179 PrintMessageString(4305);
180 else
181 ConPrintf(StdOut, L"%lu", Info0->usrmod0_force_logoff);
182 ConPuts(StdOut, L"\n");
183
184 PrintPaddedMessageString(4572, nPaddedLength);
185 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
186
187 PrintPaddedMessageString(4573, nPaddedLength);
188 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
189
190 PrintPaddedMessageString(4574, nPaddedLength);
191 ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
192
193 PrintPaddedMessageString(4575, nPaddedLength);
194 if (Info0->usrmod0_password_hist_len == 0)
195 PrintMessageString(4303);
196 else
198 ConPuts(StdOut, L"\n");
199
200 PrintPaddedMessageString(4578, nPaddedLength);
201 if (Info3->usrmod3_lockout_threshold == 0)
202 PrintMessageString(4305);
203 else
205 ConPuts(StdOut, L"\n");
206
207 PrintPaddedMessageString(4579, nPaddedLength);
208 ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
209
210 PrintPaddedMessageString(4580, nPaddedLength);
212
213 PrintPaddedMessageString(4576, nPaddedLength);
214 if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
215 {
216 if (ProductType == NtProductLanManNt)
217 {
218 PrintMessageString(5070);
219 }
220 else if (ProductType == NtProductServer)
221 {
222 PrintMessageString(5073);
223 }
224 else
225 {
226 PrintMessageString(5072);
227 }
228 }
229 else
230 {
231 PrintMessageString(5071);
232 }
233 ConPuts(StdOut, L"\n");
234 }
235
236done:
237 if (Info3 != NULL)
238 NetApiBufferFree(Info3);
239
240 if (Info1 != NULL)
241 NetApiBufferFree(Info1);
242
243 if (Info0 != NULL)
244 NetApiBufferFree(Info0);
245
246 return result;
247}
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
#define StdErr
Definition: fc.c:15
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:239
VOID PrintPaddedMessageString(DWORD dwMessage, INT nPaddedLength)
Definition: main.c:143
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:93
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:120
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI RtlGetNtProductType(_Out_ PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetUserModalsSet(IN LPCWSTR servername, IN DWORD level, IN LPBYTE buf, OUT LPDWORD parm_err)
Definition: user.c:3943
NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR servername, DWORD level, LPBYTE *bufptr)
Definition: user.c:3659
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
@ NtProductWinNt
Definition: shellpath.c:64
@ NtProductLanManNt
Definition: shellpath.c:65
@ NtProductServer
Definition: shellpath.c:66
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304
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
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define ULONG_MAX
Definition: intsafe.h:155
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define UAS_ROLE_PRIMARY
Definition: lmaccess.h:53
#define NERR_Success
Definition: lmerr.h:5
#define argv
Definition: mplay32.c:18
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_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)
DWORD usrmod0_min_passwd_age
Definition: lmaccess.h:435
DWORD usrmod0_force_logoff
Definition: lmaccess.h:436
DWORD usrmod0_min_passwd_len
Definition: lmaccess.h:433
DWORD usrmod0_max_passwd_age
Definition: lmaccess.h:434
DWORD usrmod0_password_hist_len
Definition: lmaccess.h:437
DWORD usrmod3_lockout_observation_window
Definition: lmaccess.h:449
DWORD usrmod3_lockout_threshold
Definition: lmaccess.h:450
DWORD usrmod3_lockout_duration
Definition: lmaccess.h:448
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
WCHAR * LPWSTR
Definition: xmlstorage.h:184