ReactOS 0.4.16-dev-340-g0540c21
net.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <wincon.h>
#include <winsvc.h>
#include <winnetwk.h>
#include <lm.h>
#include <ndk/rtlfuncs.h>
#include <strsafe.h>
#include <conutils.h>
#include <net_msg.h>
Include dependency graph for net.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

VOID PrintPaddedResourceString (UINT uID, INT nPaddedLength)
 
VOID PrintPadding (WCHAR chr, INT nPaddedLength)
 
DWORD TranslateAppMessage (DWORD dwMessage)
 
VOID PrintMessageString (DWORD dwMessage)
 
VOID PrintMessageStringV (DWORD dwMessage,...)
 
VOID PrintPaddedMessageString (DWORD dwMessage, INT nPaddedLength)
 
VOID PrintErrorMessage (DWORD dwError)
 
VOID PrintNetMessage (DWORD dwMessage)
 
VOID ReadFromConsole (LPWSTR lpInput, DWORD dwLength, BOOL bEcho)
 
VOID help (VOID)
 
INT unimplemented (INT argc, WCHAR **argv)
 
INT cmdAccounts (INT argc, WCHAR **argv)
 
INT cmdComputer (INT argc, WCHAR **argv)
 
INT cmdConfig (INT argc, WCHAR **argv)
 
INT cmdContinue (INT argc, WCHAR **argv)
 
INT cmdGroup (INT argc, WCHAR **argv)
 
INT cmdHelp (INT argc, WCHAR **argv)
 
INT cmdHelpMsg (INT argc, WCHAR **argv)
 
INT cmdLocalGroup (INT argc, WCHAR **argv)
 
INT cmdPause (INT argc, WCHAR **argv)
 
INT cmdSession (INT argc, WCHAR **argv)
 
INT cmdShare (INT argc, WCHAR **argv)
 
INT cmdStart (INT argc, WCHAR **argv)
 
INT cmdStatistics (INT argc, WCHAR **argv)
 
INT cmdStop (INT argc, WCHAR **argv)
 
INT cmdSyntax (INT argc, WCHAR **argv)
 
INT cmdUse (INT argc, WCHAR **argv)
 
INT cmdUser (INT argc, WCHAR **argv)
 

Variables

HMODULE hModuleNetMsg
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 15 of file net.h.

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

◆ cmdComputer()

INT cmdComputer ( INT  argc,
WCHAR **  argv 
)

Definition at line 11 of file cmdComputer.c.

14{
15 WCHAR ComputerAccountName[MAX_PATH + 2];
16 WCHAR ComputerPassword[LM20_PWLEN + 1];
17 USER_INFO_1 UserInfo;
18 INT i, result = 0;
19 BOOL bAdd = FALSE;
20 BOOL bDelete = FALSE;
21 PWSTR pComputerName = NULL;
23/*
24 OSVERSIONINFOEX VersionInfo;
25
26 VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
27 if (!GetVersionEx((LPOSVERSIONINFO)&VersionInfo))
28 {
29 PrintErrorMessage(GetLastError());
30 return 1;
31 }
32
33 if (VersionInfo.wProductType != VER_NT_DOMAIN_CONTROLLER)
34 {
35 PrintErrorMessage(3515);
36 return 1;
37 }
38*/
39
40 i = 2;
41 if (argc > 2 && argv[i][0] == L'\\' && argv[i][1] == L'\\')
42 {
43 pComputerName = argv[i];
44 i++;
45 }
46
47 for (; i < argc; i++)
48 {
49 if (_wcsicmp(argv[i], L"help") == 0)
50 {
51 /* Print short syntax help */
53 ConPuts(StdOut, L"\n");
54 PrintNetMessage(MSG_COMPUTER_SYNTAX);
55 return 0;
56 }
57
58 if (_wcsicmp(argv[i], L"/help") == 0)
59 {
60 /* Print full help text*/
62 ConPuts(StdOut, L"\n");
63 PrintNetMessage(MSG_COMPUTER_SYNTAX);
64 PrintNetMessage(MSG_COMPUTER_HELP);
65 return 0;
66 }
67
68 if (_wcsicmp(argv[i], L"/add") == 0)
69 {
70 bAdd = TRUE;
71 continue;
72 }
73 else if (_wcsicmp(argv[i], L"/del") == 0)
74 {
75 bDelete = TRUE;
76 continue;
77 }
78 else
79 {
80 PrintErrorMessage(3506/*, argv[i]*/);
81 return 1;
82 }
83 }
84
85 if (pComputerName == NULL ||
86 (bAdd == FALSE && bDelete == FALSE) ||
87 (bAdd == TRUE && bDelete == TRUE))
88 {
90 ConPuts(StdOut, L"\n");
91 PrintNetMessage(MSG_COMPUTER_SYNTAX);
92 return 1;
93 }
94
95 /*
96 * Create the computer account name:
97 * Skip the leading '\\' and appand a '$'.
98 */
99 wcscpy(ComputerAccountName, &pComputerName[2]);
100 wcscat(ComputerAccountName, L"$");
101
102 if (bAdd)
103 {
104 /*
105 * Create the computer password:
106 * Skip the leading '\\', shorten to a maximum of 14 characters
107 * and convert to lower case
108 */
109 wcsncpy(ComputerPassword, &pComputerName[2], LM20_PWLEN);
110 ComputerPassword[LM20_PWLEN] = UNICODE_NULL;
111 _wcslwr(ComputerPassword);
112
113 /* Set the account data */
114 UserInfo.usri1_name = ComputerAccountName;
115 UserInfo.usri1_password = ComputerPassword;
116 UserInfo.usri1_password_age = 0;
117 UserInfo.usri1_priv = USER_PRIV_USER;
118 UserInfo.usri1_home_dir = NULL;
119 UserInfo.usri1_comment = NULL;
121 UserInfo.usri1_script_path = NULL;
122
123 /* Add the computer account */
125 1,
126 (LPBYTE)&UserInfo,
127 NULL);
128 }
129 else if (bDelete)
130 {
131 /* Delete the coputer account */
133 ComputerAccountName);
134 }
135
136 if (Status == NERR_Success)
137 {
139 }
140 else
141 {
143 result = 1;
144 }
145
146 return result;
147}
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_PATH
Definition: compat.h:34
NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
Definition: user.c:2273
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
Definition: user.c:2543
#define USER_PRIV_USER
Definition: lmaccess.h:117
#define UF_SCRIPT
Definition: lmaccess.h:23
#define UF_WORKSTATION_TRUST_ACCOUNT
Definition: lmaccess.h:32
#define LM20_PWLEN
Definition: lmcons.h:38
#define UNICODE_NULL
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl _wcslwr(_Inout_z_ wchar_t *_String)
DWORD usri1_flags
Definition: lmaccess.h:209
LPWSTR usri1_comment
Definition: lmaccess.h:208
DWORD usri1_password_age
Definition: lmaccess.h:205
LPWSTR usri1_name
Definition: lmaccess.h:203
LPWSTR usri1_script_path
Definition: lmaccess.h:210
LPWSTR usri1_home_dir
Definition: lmaccess.h:207
LPWSTR usri1_password
Definition: lmaccess.h:204
DWORD usri1_priv
Definition: lmaccess.h:206
uint16_t * PWSTR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ cmdConfig()

INT cmdConfig ( INT  argc,
WCHAR **  argv 
)

Definition at line 165 of file cmdConfig.c.

168{
169 INT i, result = 0;
170 BOOL bServer = FALSE;
171 BOOL bWorkstation = FALSE;
172 PWSTR p, endptr;
173 BOOL bModify = FALSE;
174 LONG lValue;
175 PSERVER_INFO_102 ServerInfo = NULL;
177
178 for (i = 2; i < argc; i++)
179 {
180 if (_wcsicmp(argv[i], L"server") == 0)
181 {
182 if (bWorkstation == FALSE)
183 bServer = TRUE;
184 continue;
185 }
186
187 if (_wcsicmp(argv[i], L"workstation") == 0)
188 {
189 if (bServer == FALSE)
190 bWorkstation = TRUE;
191 continue;
192 }
193
194 if (_wcsicmp(argv[i], L"help") == 0)
195 {
196 /* Print short syntax help */
197 if (bServer == TRUE)
198 {
199 PrintMessageString(4381);
200 ConPuts(StdOut, L"\n");
201 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
202 }
203 else
204 {
205 PrintMessageString(4381);
206 ConPuts(StdOut, L"\n");
207 PrintNetMessage(MSG_CONFIG_SYNTAX);
208 }
209 return 0;
210 }
211
212 if (_wcsicmp(argv[i], L"/help") == 0)
213 {
214 /* Print full help text*/
215 if (bServer == TRUE)
216 {
217 PrintMessageString(4381);
218 ConPuts(StdOut, L"\n");
219 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
220 PrintNetMessage(MSG_CONFIG_SERVER_HELP);
221 }
222 else
223 {
224 PrintMessageString(4381);
225 ConPuts(StdOut, L"\n");
226 PrintNetMessage(MSG_CONFIG_SYNTAX);
227 PrintNetMessage(MSG_CONFIG_HELP);
228 }
229 return 0;
230 }
231 }
232
233 if (bServer)
234 {
235 Status = NetServerGetInfo(NULL, 102, (PBYTE*)&ServerInfo);
236 if (Status != NERR_Success)
237 goto done;
238
239 for (i = 2; i < argc; i++)
240 {
241 if (argv[i][0] != L'/')
242 continue;
243
244 if (_wcsnicmp(argv[i], L"/autodisconnect:", 16) == 0)
245 {
246 p = &argv[i][16];
247 lValue = wcstol(p, &endptr, 10);
248 if (*endptr != 0)
249 {
250 PrintMessageStringV(3952, L"/AUTODISCONNECT");
251 result = 1;
252 goto done;
253 }
254
255 if (lValue < -1 || lValue > 65535)
256 {
257 PrintMessageStringV(3952, L"/AUTODISCONNECT");
258 result = 1;
259 goto done;
260 }
261
262 ServerInfo->sv102_disc = lValue;
263 bModify = TRUE;
264 }
265 else if (_wcsnicmp(argv[i], L"/srvcomment:", 12) == 0)
266 {
267 ServerInfo->sv102_comment = &argv[i][12];
268 bModify = TRUE;
269 }
270 else if (_wcsnicmp(argv[i], L"/hidden:", 8) == 0)
271 {
272 p = &argv[i][8];
273 if (_wcsicmp(p, L"yes") != 0 && _wcsicmp(p, L"no") != 0)
274 {
275 PrintMessageStringV(3952, L"/HIDDEN");
276 result = 1;
277 goto done;
278 }
279
280 ServerInfo->sv102_hidden = (_wcsicmp(p, L"yes") == 0) ? TRUE : FALSE;
281 bModify = TRUE;
282 }
283 else
284 {
285 PrintMessageString(4381);
286 ConPuts(StdOut, L"\n");
287 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
288 result = 1;
289 goto done;
290 }
291 }
292
293 if (bModify)
294 {
295 Status = NetServerSetInfo(NULL, 102, (PBYTE)&ServerInfo, NULL);
296 if (Status != NERR_Success)
297 result = 1;
298 }
299 else
300 {
301 result = DisplayServerConfig(ServerInfo);
302 }
303 }
304 else if (bWorkstation)
305 {
307 }
308 else
309 {
310 PrintMessageString(4378);
311 ConPuts(StdOut, L"\n");
312 ConPuts(StdOut, L" Server\n");
313 ConPuts(StdOut, L" Workstation\n");
314 ConPuts(StdOut, L"\n");
315 }
316
317done:
318 if (ServerInfo != NULL)
319 NetApiBufferFree(ServerInfo);
320
321 if (result == 0)
323
324 return result;
325}
static INT DisplayServerConfig(PSERVER_INFO_102 ServerInfo)
Definition: cmdConfig.c:12
static INT DisplayWorkstationConfig(VOID)
Definition: cmdConfig.c:75
NET_API_STATUS WINAPI NetServerSetInfo(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:399
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
LPWSTR sv102_comment
Definition: lmserver.h:31
BOOL sv102_hidden
Definition: lmserver.h:34

◆ cmdContinue()

INT cmdContinue ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdContinue.c.

13{
14 SC_HANDLE hManager = NULL;
15 SC_HANDLE hService = NULL;
17 INT nError = 0;
18 INT i;
19
20 if (argc != 3)
21 {
23 ConPuts(StdOut, L"\n");
24 PrintNetMessage(MSG_CONTINUE_SYNTAX);
25 return 1;
26 }
27
28 for (i = 2; i < argc; i++)
29 {
30 if (_wcsicmp(argv[i], L"/help") == 0)
31 {
33 ConPuts(StdOut, L"\n");
34 PrintNetMessage(MSG_CONTINUE_SYNTAX);
35 PrintNetMessage(MSG_CONTINUE_HELP);
36 return 1;
37 }
38 }
39
41 if (hManager == NULL)
42 {
43 ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
44 nError = 1;
45 goto done;
46 }
47
48 hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
49 if (hService == NULL)
50 {
51 ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
52 nError = 1;
53 goto done;
54 }
55
57 {
58 ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
59 nError = 1;
60 }
61
62done:
63 if (hService != NULL)
64 CloseServiceHandle(hService);
65
66 if (hManager != NULL)
67 CloseServiceHandle(hManager);
68
69 return nError;
70}
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:622
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
Definition: ps.c:97
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define OpenSCManager
Definition: winsvc.h:575
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
#define SERVICE_PAUSE_CONTINUE
Definition: winsvc.h:59
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
#define OpenService
Definition: winsvc.h:576

◆ cmdGroup()

INT cmdGroup ( INT  argc,
WCHAR **  argv 
)

Definition at line 154 of file cmdGroup.c.

157{
158 INT i, j;
159 INT result = 0;
160 ULONG dwUserCount = 0;
161 BOOL bAdd = FALSE;
162 BOOL bDelete = FALSE;
163#if 0
164 BOOL bDomain = FALSE;
165#endif
166 PWSTR pGroupName = NULL;
167 PWSTR pComment = NULL;
168 PWSTR *pUsers = NULL;
169 GROUP_INFO_0 Info0;
170 GROUP_INFO_1 Info1;
171 GROUP_INFO_1002 Info1002;
173
174 if (argc == 2)
175 {
177 ConPrintf(StdOut, L"Status: %lu\n", Status);
178 return 0;
179 }
180 else if (argc == 3)
181 {
183 ConPrintf(StdOut, L"Status: %lu\n", Status);
184 return 0;
185 }
186
187 i = 2;
188 if (argv[i][0] != L'/')
189 {
190 pGroupName = argv[i];
191 i++;
192 }
193
194 for (j = i; j < argc; j++)
195 {
196 if (argv[j][0] == L'/')
197 break;
198
199 dwUserCount++;
200 }
201
202 if (dwUserCount > 0)
203 {
204 pUsers = RtlAllocateHeap(RtlGetProcessHeap(),
206 dwUserCount * sizeof(PGROUP_USERS_INFO_0));
207 if (pUsers == NULL)
208 return 0;
209 }
210
211 j = 0;
212 for (; i < argc; i++)
213 {
214 if (argv[i][0] == L'/')
215 break;
216
217 pUsers[j] = argv[i];
218 j++;
219 }
220
221 for (; i < argc; i++)
222 {
223 if (_wcsicmp(argv[i], L"/help") == 0)
224 {
225 PrintMessageString(4381);
226 ConPuts(StdOut, L"\n");
227 PrintNetMessage(MSG_GROUP_SYNTAX);
228 PrintNetMessage(MSG_GROUP_HELP);
229 return 0;
230 }
231 else if (_wcsicmp(argv[i], L"/add") == 0)
232 {
233 bAdd = TRUE;
234 }
235 else if (_wcsicmp(argv[i], L"/delete") == 0)
236 {
237 bDelete = TRUE;
238 }
239 else if (_wcsnicmp(argv[i], L"/comment:", 9) == 0)
240 {
241 pComment = &argv[i][9];
242 }
243 else if (_wcsicmp(argv[i], L"/domain") == 0)
244 {
245 ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
246#if 0
247 bDomain = TRUE;
248#endif
249 }
250 else
251 {
252 PrintErrorMessage(3506/*, argv[i]*/);
253 result = 1;
254 goto done;
255 }
256 }
257
258 if (pGroupName == NULL)
259 {
260 result = 1;
261 goto done;
262 }
263
264 if (bAdd && bDelete)
265 {
266 result = 1;
267 goto done;
268 }
269
270 if (pUsers == NULL)
271 {
272 if (!bAdd && !bDelete && pComment != NULL)
273 {
274 /* Set group comment */
275 Info1002.grpi1002_comment = pComment;
277 pGroupName,
278 1002,
279 (LPBYTE)&Info1002,
280 NULL);
281 ConPrintf(StdOut, L"Status: %lu\n", Status);
282 }
283 else if (bAdd && !bDelete)
284 {
285 /* Add the group */
286 if (pComment == NULL)
287 {
288 Info0.grpi0_name = pGroupName;
289 }
290 else
291 {
292 Info1.grpi1_name = pGroupName;
293 Info1.grpi1_comment = pComment;
294 }
295
297 (pComment == NULL) ? 0 : 1,
298 (pComment == NULL) ? (LPBYTE)&Info0 : (LPBYTE)&Info1,
299 NULL);
300 ConPrintf(StdOut, L"Status: %lu\n", Status);
301 }
302 else if (!bAdd && bDelete && pComment == NULL)
303 {
304 /* Delete the group */
306 pGroupName);
307 ConPrintf(StdOut, L"Status: %lu\n", Status);
308 }
309 else
310 {
311 result = 1;
312 }
313 }
314 else
315 {
316 if (bAdd && !bDelete && pComment == NULL)
317 {
318 /* Add group user */
319 for (i = 0; i < dwUserCount; i++)
320 {
322 pGroupName,
323 pUsers[i]);
324 if (Status != NERR_Success)
325 break;
326 }
327 ConPrintf(StdOut, L"Status: %lu\n", Status);
328 }
329 else if (!bAdd && bDelete && pComment == NULL)
330 {
331 /* Delete group members */
332 for (i = 0; i < dwUserCount; i++)
333 {
335 pGroupName,
336 pUsers[i]);
337 if (Status != NERR_Success)
338 break;
339 }
340 ConPrintf(StdOut, L"Status: %lu\n", Status);
341 }
342 else
343 {
344 result = 1;
345 }
346 }
347
348done:
349 if (pUsers != NULL)
350 RtlFreeHeap(RtlGetProcessHeap(), 0, pUsers);
351
352 if (result != 0)
353 {
354 PrintMessageString(4381);
355 ConPuts(StdOut, L"\n");
356 PrintNetMessage(MSG_GROUP_SYNTAX);
357 }
358
359 return result;
360}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
static NET_API_STATUS DisplayGroup(LPWSTR lpGroupName)
Definition: cmdGroup.c:75
static NET_API_STATUS EnumerateGroups(VOID)
Definition: cmdGroup.c:23
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
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 GLint GLint j
Definition: glfuncs.h:250
NET_API_STATUS WINAPI NetGroupDelUser(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ LPCWSTR username)
Definition: group_new.c:665
NET_API_STATUS WINAPI NetGroupDel(_In_opt_ LPCWSTR servername, _In_ IN LPCWSTR groupname)
Definition: group_new.c:582
NET_API_STATUS WINAPI NetGroupAddUser(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ LPCWSTR username)
Definition: group_new.c:466
NET_API_STATUS WINAPI NetGroupAdd(_In_opt_ LPCWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_opt_ LPDWORD parm_err)
Definition: group_new.c:286
NET_API_STATUS WINAPI NetGroupSetInfo(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ DWORD level, _In_ LPBYTE buf, _Out_opt_ LPDWORD parm_err)
Definition: group_new.c:1382
LPWSTR grpi0_name
Definition: lmaccess.h:474
LPWSTR grpi1002_comment
Definition: lmaccess.h:493
LPWSTR grpi1_name
Definition: lmaccess.h:477
LPWSTR grpi1_comment
Definition: lmaccess.h:478

◆ cmdHelp()

INT cmdHelp ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdHelp.c.

13{
15 ConPuts(StdOut, L"\n");
16
17 if (argc != 3)
18 {
19 PrintNetMessage(MSG_HELP_SYNTAX);
20 PrintNetMessage(MSG_HELP_HELP);
21 return 0;
22 }
23
24 if (_wcsicmp(argv[2], L"ACCOUNTS") == 0)
25 {
26 PrintNetMessage(MSG_ACCOUNTS_SYNTAX);
27 PrintNetMessage(MSG_ACCOUNTS_HELP);
28 return 0;
29 }
30
31 if (_wcsicmp(argv[2], L"COMPUTER") == 0)
32 {
33 PrintNetMessage(MSG_COMPUTER_SYNTAX);
34 PrintNetMessage(MSG_COMPUTER_HELP);
35 return 0;
36 }
37
38 if (_wcsicmp(argv[2], L"CONFIG") == 0)
39 {
40 if ((argc > 3) && (_wcsicmp(argv[3], L"SERVER") == 0))
41 {
42 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
43 PrintNetMessage(MSG_CONFIG_SERVER_HELP);
44 return 0;
45 }
46 else
47 {
48 PrintNetMessage(MSG_CONFIG_SYNTAX);
49 PrintNetMessage(MSG_CONFIG_HELP);
50 return 0;
51 }
52 }
53
54 if (_wcsicmp(argv[2], L"CONTINUE") == 0)
55 {
56 PrintNetMessage(MSG_CONTINUE_SYNTAX);
57 PrintNetMessage(MSG_CONTINUE_HELP);
58 return 0;
59 }
60
61 if (_wcsicmp(argv[2], L"FILE") == 0)
62 {
63 PrintNetMessage(MSG_FILE_SYNTAX);
64 PrintNetMessage(MSG_FILE_HELP);
65 return 0;
66 }
67
68 if (_wcsicmp(argv[2], L"GROUP") == 0)
69 {
70 PrintNetMessage(MSG_GROUP_SYNTAX);
71 PrintNetMessage(MSG_GROUP_HELP);
72 return 0;
73 }
74
75 if (_wcsicmp(argv[2], L"HELPMSG") == 0)
76 {
77 PrintNetMessage(MSG_HELPMSG_SYNTAX);
78 PrintNetMessage(MSG_HELPMSG_HELP);
79 return 0;
80 }
81
82 if (_wcsicmp(argv[2], L"LOCALGROUP") == 0)
83 {
84 PrintNetMessage(MSG_LOCALGROUP_SYNTAX);
85 PrintNetMessage(MSG_LOCALGROUP_HELP);
86 return 0;
87 }
88
89 if (_wcsicmp(argv[2], L"PAUSE") == 0)
90 {
91 PrintNetMessage(MSG_PAUSE_SYNTAX);
92 PrintNetMessage(MSG_PAUSE_HELP);
93 return 0;
94 }
95
96 if (_wcsicmp(argv[2], L"SESSION") == 0)
97 {
98 PrintNetMessage(MSG_SESSION_SYNTAX);
99 PrintNetMessage(MSG_SESSION_HELP);
100 return 0;
101 }
102
103 if (_wcsicmp(argv[2], L"SHARE") == 0)
104 {
105 PrintNetMessage(MSG_SHARE_SYNTAX);
106 PrintNetMessage(MSG_SHARE_HELP);
107 return 0;
108 }
109
110 if (_wcsicmp(argv[2], L"START") == 0)
111 {
112 PrintNetMessage(MSG_START_SYNTAX);
113 PrintNetMessage(MSG_START_HELP);
114 return 0;
115 }
116
117 if (_wcsicmp(argv[2], L"STATISTICS") == 0)
118 {
119 PrintNetMessage(MSG_STATISTICS_SYNTAX);
120 PrintNetMessage(MSG_STATISTICS_HELP);
121 return 0;
122 }
123
124 if (_wcsicmp(argv[2], L"STOP") == 0)
125 {
126 PrintNetMessage(MSG_STOP_SYNTAX);
127 PrintNetMessage(MSG_STOP_HELP);
128 return 0;
129 }
130
131 if (_wcsicmp(argv[2], L"TIME") == 0)
132 {
133 PrintNetMessage(MSG_TIME_SYNTAX);
134 PrintNetMessage(MSG_TIME_HELP);
135 return 0;
136 }
137
138 if (_wcsicmp(argv[2], L"USE") == 0)
139 {
140 PrintNetMessage(MSG_USE_SYNTAX);
141 PrintNetMessage(MSG_USE_HELP);
142 return 0;
143 }
144
145 if (_wcsicmp(argv[2], L"USER") == 0)
146 {
147 PrintNetMessage(MSG_USER_SYNTAX);
148 PrintNetMessage(MSG_USER_HELP);
149 return 0;
150 }
151
152 if (_wcsicmp(argv[2], L"VIEW") == 0)
153 {
154 PrintNetMessage(MSG_VIEW_SYNTAX);
155 PrintNetMessage(MSG_VIEW_HELP);
156 return 0;
157 }
158
159#if 0
160 if (_wcsicmp(argv[2], L"SERVICES") == 0)
161 {
162 return 0;
163 }
164#endif
165
166 if (_wcsicmp(argv[2], L"SYNTAX") == 0)
167 {
168 PrintNetMessage(MSG_SYNTAX_HELP);
169 return 0;
170 }
171
172 PrintNetMessage(MSG_HELP_SYNTAX);
173 PrintNetMessage(MSG_HELP_HELP);
174
175 return 0;
176}

◆ cmdHelpMsg()

INT cmdHelpMsg ( INT  argc,
WCHAR **  argv 
)

Definition at line 14 of file cmdHelpMsg.c.

15{
16 INT i;
17 LONG errNum;
18 PWSTR endptr;
20 PWSTR pInserts[10] = {L"***", L"***", L"***", L"***",
21 L"***", L"***", L"***", L"***",
22 L"***", NULL};
23
24 if (argc < 3)
25 {
27 ConPuts(StdOut, L"\n");
28 PrintNetMessage(MSG_HELPMSG_SYNTAX);
29 return 1;
30 }
31
32 for (i = 2; i < argc; i++)
33 {
34 if (_wcsicmp(argv[i], L"/help") == 0)
35 {
37 ConPuts(StdOut, L"\n");
38 PrintNetMessage(MSG_HELPMSG_SYNTAX);
39 PrintNetMessage(MSG_HELPMSG_HELP);
40 return 1;
41 }
42 }
43
44 errNum = wcstol(argv[2], &endptr, 10);
45 if (*endptr != 0)
46 {
48 ConPuts(StdOut, L"\n");
49 PrintNetMessage(MSG_HELPMSG_SYNTAX);
50 return 1;
51 }
52
53 if (errNum >= MIN_LANMAN_MESSAGE_ID && errNum <= MAX_LANMAN_MESSAGE_ID)
54 {
58 errNum,
61 0,
62 (va_list *)pInserts);
63 if (pBuffer)
64 {
65 ConPrintf(StdOut, L"\n%s\n", pBuffer);
67 }
68 else
69 {
71 }
72 }
73 else
74 {
75 /* Retrieve the message string without appending extra newlines */
78 NULL,
79 errNum,
82 0,
83 (va_list *)pInserts);
84 if (pBuffer)
85 {
86 ConPrintf(StdOut, L"\n%s\n", pBuffer);
88 }
89 else
90 {
92 }
93 }
94
95 return 0;
96}
char * va_list
Definition: acmsvcex.h:78
HMODULE hModuleNetMsg
Definition: main.c:46
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define MAX_LANMAN_MESSAGE_ID
Definition: lmcons.h:11
#define MIN_LANMAN_MESSAGE_ID
Definition: lmcons.h:10
PVOID pBuffer
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448

◆ cmdLocalGroup()

INT cmdLocalGroup ( INT  argc,
WCHAR **  argv 
)

Definition at line 172 of file cmdLocalGroup.c.

175{
176 INT i, j;
177 INT result = 0;
178 ULONG dwMemberCount = 0;
179 BOOL bAdd = FALSE;
180 BOOL bDelete = FALSE;
181#if 0
182 BOOL bDomain = FALSE;
183#endif
184 LPWSTR lpGroupName = NULL;
185 LPWSTR lpComment = NULL;
187 LOCALGROUP_INFO_0 Info0;
188 LOCALGROUP_INFO_1 Info1;
189 LOCALGROUP_INFO_1002 Info1002;
191
192 if (argc == 2)
193 {
195 ConPrintf(StdOut, L"Status: %lu\n", Status);
196 return 0;
197 }
198 else if (argc == 3)
199 {
201 ConPrintf(StdOut, L"Status: %lu\n", Status);
202 return 0;
203 }
204
205 i = 2;
206 if (argv[i][0] != L'/')
207 {
208 lpGroupName = argv[i];
209 i++;
210 }
211
212 for (j = i; j < argc; j++)
213 {
214 if (argv[j][0] == L'/')
215 break;
216
217 dwMemberCount++;
218 }
219
220 ConPrintf(StdOut, L"Member count: %lu\n", dwMemberCount);
221
222 if (dwMemberCount > 0)
223 {
224 lpMembers = RtlAllocateHeap(RtlGetProcessHeap(),
226 dwMemberCount * sizeof(LPLOCALGROUP_MEMBERS_INFO_3));
227 if (lpMembers == NULL)
228 return 0;
229 }
230
231 j = 0;
232 for (; i < argc; i++)
233 {
234 if (argv[i][0] == L'/')
235 break;
236
237 lpMembers[j].lgrmi3_domainandname = argv[i];
238 j++;
239 }
240
241 for (; i < argc; i++)
242 {
243 if (_wcsicmp(argv[i], L"/help") == 0)
244 {
245 PrintMessageString(4381);
246 ConPuts(StdOut, L"\n");
247 PrintNetMessage(MSG_LOCALGROUP_SYNTAX);
248 PrintNetMessage(MSG_LOCALGROUP_HELP);
249 return 0;
250 }
251 else if (_wcsicmp(argv[i], L"/add") == 0)
252 {
253 bAdd = TRUE;
254 }
255 else if (_wcsicmp(argv[i], L"/delete") == 0)
256 {
257 bDelete = TRUE;
258 }
259 else if (_wcsnicmp(argv[i], L"/comment:", 9) == 0)
260 {
261 lpComment = &argv[i][9];
262 }
263 else if (_wcsicmp(argv[i], L"/domain") == 0)
264 {
265 ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
266#if 0
267 bDomain = TRUE;
268#endif
269 }
270 else
271 {
272 PrintErrorMessage(3506/*, argv[i]*/);
273 result = 1;
274 goto done;
275 }
276 }
277
278 if (lpGroupName == NULL)
279 {
280 result = 1;
281 goto done;
282 }
283
284 if (bAdd && bDelete)
285 {
286 result = 1;
287 goto done;
288 }
289
290#if 0
291 ConPrintf(StdOut, L"Group:\n %s\n", lpGroupName);
292
293 if (lpMembers != NULL)
294 {
295 ConPuts(StdOut, L"\nMembers:\n");
296 for (i = 0; i < dwMemberCount; i++)
297 ConPrintf(StdOut, L" %s\n", lpMembers[i].lgrmi3_domainandname);
298 }
299
300 if (lpComment != NULL)
301 {
302 ConPrintf(StdOut, L"\nComment:\n %s\n", lpComment);
303 }
304#endif
305
306 if (lpMembers == NULL)
307 {
308 if (!bAdd && !bDelete && lpComment != NULL)
309 {
310 /* Set group comment */
311 Info1002.lgrpi1002_comment = lpComment;
313 lpGroupName,
314 1002,
315 (LPBYTE)&Info1002,
316 NULL);
317 ConPrintf(StdOut, L"Status: %lu\n", Status);
318 }
319 else if (bAdd && !bDelete)
320 {
321 /* Add the group */
322 if (lpComment == NULL)
323 {
324 Info0.lgrpi0_name = lpGroupName;
325 }
326 else
327 {
328 Info1.lgrpi1_name = lpGroupName;
329 Info1.lgrpi1_comment = lpComment;
330 }
331
333 (lpComment == NULL) ? 0 : 1,
334 (lpComment == NULL) ? (LPBYTE)&Info0 : (LPBYTE)&Info1,
335 NULL);
336 ConPrintf(StdOut, L"Status: %lu\n", Status);
337 }
338 else if (!bAdd && bDelete && lpComment == NULL)
339 {
340 /* Delete the group */
342 lpGroupName);
343 ConPrintf(StdOut, L"Status: %lu\n", Status);
344 }
345 else
346 {
347 result = 1;
348 }
349 }
350 else
351 {
352 if (bAdd && !bDelete && lpComment == NULL)
353 {
354 /* Add group members */
356 lpGroupName,
357 3,
358 (LPBYTE)lpMembers,
359 dwMemberCount);
360 ConPrintf(StdOut, L"Status: %lu\n", Status);
361 }
362 else if (!bAdd && bDelete && lpComment == NULL)
363 {
364 /* Delete group members */
366 lpGroupName,
367 3,
368 (LPBYTE)lpMembers,
369 dwMemberCount);
370 ConPrintf(StdOut, L"Status: %lu\n", Status);
371 }
372 else
373 {
374 result = 1;
375 }
376 }
377
378done:
379 if (lpMembers != NULL)
380 RtlFreeHeap(RtlGetProcessHeap(), 0, lpMembers);
381
382 if (result != 0)
383 {
384 PrintMessageString(4381);
385 ConPuts(StdOut, L"\n");
386 PrintNetMessage(MSG_LOCALGROUP_SYNTAX);
387 }
388
389 return result;
390}
static NET_API_STATUS EnumerateLocalGroups(VOID)
Definition: cmdLocalGroup.c:25
static NET_API_STATUS DisplayLocalGroup(LPWSTR lpGroupName)
Definition: cmdLocalGroup.c:78
NET_API_STATUS WINAPI NetLocalGroupDelMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:817
NET_API_STATUS WINAPI NetLocalGroupSetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:1732
NET_API_STATUS WINAPI NetLocalGroupAdd(LPCWSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:334
NET_API_STATUS WINAPI NetLocalGroupDel(LPCWSTR servername, LPCWSTR groupname)
Definition: local_group.c:677
NET_API_STATUS WINAPI NetLocalGroupAddMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:520
LPWSTR lgrpi0_name
Definition: lmaccess.h:506
LPWSTR lgrpi1002_comment
Definition: lmaccess.h:513
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
LPWSTR lgrpi1_name
Definition: lmaccess.h:509

◆ cmdPause()

INT cmdPause ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdPause.c.

13{
14 SC_HANDLE hManager = NULL;
15 SC_HANDLE hService = NULL;
17 INT nError = 0;
18 INT i;
19
20 if (argc != 3)
21 {
23 ConPuts(StdOut, L"\n");
24 PrintNetMessage(MSG_PAUSE_SYNTAX);
25 return 1;
26 }
27
28 for (i = 2; i < argc; i++)
29 {
30 if (_wcsicmp(argv[i], L"/help") == 0)
31 {
33 ConPuts(StdOut, L"\n");
34 PrintNetMessage(MSG_PAUSE_SYNTAX);
35 PrintNetMessage(MSG_PAUSE_HELP);
36 return 1;
37 }
38 }
39
41 if (hManager == NULL)
42 {
43 ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
44 nError = 1;
45 goto done;
46 }
47
48 hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
49 if (hService == NULL)
50 {
51 ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
52 nError = 1;
53 goto done;
54 }
55
57 {
58 ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
59 }
60
61done:
62 if (hService != NULL)
63 CloseServiceHandle(hService);
64
65 if (hManager != NULL)
66 CloseServiceHandle(hManager);
67
68 return nError;
69}
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37

◆ cmdSession()

INT cmdSession ( INT  argc,
WCHAR **  argv 
)

◆ cmdShare()

INT cmdShare ( INT  argc,
WCHAR **  argv 
)

Definition at line 94 of file cmdShare.c.

97{
98 SHARE_INFO_2 ShareInfo;
99 PWSTR pszShareName = NULL;
100 PWSTR pszSharePath = NULL;
101 PWSTR ptr;
102 BOOL bDelete = FALSE;
103 INT len;
104 INT i, result = 0;
106
107 i = 2;
108 if (argc > 2 && argv[i][0] != L'/')
109 {
110 ptr = wcschr(argv[i], L'=');
111 if (ptr != NULL)
112 {
113 if (ptr[1] != UNICODE_NULL)
114 {
115 len = wcslen(&ptr[i]);
116 pszSharePath = HeapAlloc(GetProcessHeap(),
118 (len + 1) * sizeof(WCHAR));
119 if (pszSharePath == NULL)
120 {
121 // FIXME: Proper error code!
122 return 1;
123 }
124
125 wcscpy(pszSharePath, &ptr[1]);
126 }
127
128 len = ((INT_PTR)ptr - (INT_PTR)argv[i]) / sizeof(WCHAR);
129 pszShareName = HeapAlloc(GetProcessHeap(),
131 (len + 1) * sizeof(WCHAR));
132 if (pszShareName == NULL)
133 {
134 // FIXME: Proper error code!
135 return 1;
136 }
137
138 wcsncpy(pszShareName, argv[i], len);
139 }
140 else
141 {
142 len = wcslen(argv[i]);
143 pszShareName = HeapAlloc(GetProcessHeap(),
145 (len + 1) * sizeof(WCHAR));
146 if (pszShareName == NULL)
147 {
148 // FIXME: Proper error code!
149 return 1;
150 }
151
152 wcscpy(pszShareName, argv[i]);
153 }
154
155 i++;
156 }
157
158 for (; i < argc; i++)
159 {
160 if (_wcsicmp(argv[i], L"/help") == 0)
161 {
162 /* Print full help text*/
163 PrintMessageString(4381);
164 ConPuts(StdOut, L"\n");
165 PrintNetMessage(MSG_SHARE_SYNTAX);
166 PrintNetMessage(MSG_SHARE_HELP);
167 return 0;
168 }
169 else if (_wcsicmp(argv[i], L"/delete") == 0)
170 {
171 bDelete = TRUE;
172 }
173 }
174
175 printf("pszShareName: '%S'\n", pszShareName);
176 printf("pszSharePath: '%S'\n", pszSharePath);
177
178 if (pszShareName == NULL && pszSharePath == NULL)
179 {
181 ConPrintf(StdOut, L"Status: %lu\n", Status);
182 }
183 else if (pszShareName != NULL && pszSharePath == NULL)
184 {
185 if (bDelete == TRUE)
186 {
188 pszShareName,
189 0);
190 }
191 else
192 {
193 Status = DisplayShare(pszShareName);
194 }
195
196 ConPrintf(StdOut, L"Status: %lu\n", Status);
197 }
198 else if (pszShareName != NULL && pszSharePath != NULL)
199 {
200 ZeroMemory(&ShareInfo, sizeof(SHARE_INFO_2));
201 ShareInfo.shi2_netname = pszShareName;
202 ShareInfo.shi2_path = pszSharePath;
203
205 2,
206 (LPBYTE)&ShareInfo,
207 NULL);
208
209 ConPrintf(StdOut, L"Status: %lu\n", Status);
210 }
211
212 if (pszSharePath != NULL)
213 HeapFree(GetProcessHeap(), 0, pszSharePath);
214
215 if (pszShareName != NULL)
216 HeapFree(GetProcessHeap(), 0, pszShareName);
217
218 return result;
219}
NET_API_STATUS EnumerateShares(VOID)
Definition: cmdShare.c:12
NET_API_STATUS DisplayShare(PWSTR pShareName)
Definition: cmdShare.c:52
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
NET_API_STATUS WINAPI NetShareDel(_In_ LMSTR servername, _In_ LMSTR netname, _In_ DWORD reserved)
Definition: srvsvc.c:911
NET_API_STATUS WINAPI NetShareAdd(_In_ LMSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:850
#define printf
Definition: freeldr.h:97
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PVOID ptr
Definition: dispmode.c:27
LPTSTR shi2_path
Definition: lmshare.h:57
LPTSTR shi2_netname
Definition: lmshare.h:51
int32_t INT_PTR
Definition: typedefs.h:64
#define ZeroMemory
Definition: winbase.h:1737

◆ cmdStart()

INT cmdStart ( INT  argc,
WCHAR **  argv 
)

Definition at line 172 of file cmdStart.c.

173{
174 INT i;
175
176 if (argc == 2)
177 {
179 }
180
181 for (i = 2; i < argc; i++)
182 {
183 if (_wcsicmp(argv[i], L"/help") == 0)
184 {
185 PrintMessageString(4381);
186 ConPuts(StdOut, L"\n");
187 PrintNetMessage(MSG_START_SYNTAX);
188 PrintNetMessage(MSG_START_HELP);
189 return 1;
190 }
191 }
192
193 return StartOneService(argc, argv);
194}
static INT StartOneService(INT argc, WCHAR **argv)
Definition: cmdStart.c:100
static INT EnumerateRunningServices(VOID)
Definition: cmdStart.c:15

Referenced by CommandShell().

◆ cmdStatistics()

INT cmdStatistics ( INT  argc,
WCHAR **  argv 
)

Definition at line 248 of file cmdStatistics.c.

251{
252 INT i, result = 0;
253 BOOL bServer = FALSE;
254 BOOL bWorkstation = FALSE;
255
256 for (i = 2; i < argc; i++)
257 {
258 if (_wcsicmp(argv[i], L"server") == 0)
259 {
260 if (bWorkstation == FALSE)
261 bServer = TRUE;
262 continue;
263 }
264
265 if (_wcsicmp(argv[i], L"workstation") == 0)
266 {
267 if (bServer == FALSE)
268 bWorkstation = TRUE;
269 continue;
270 }
271
272 if (_wcsicmp(argv[i], L"help") == 0)
273 {
274 /* Print short syntax help */
275 PrintMessageString(4381);
276 ConPuts(StdOut, L"\n");
277 PrintNetMessage(MSG_STATISTICS_SYNTAX);
278 return 0;
279 }
280
281 if (_wcsicmp(argv[i], L"/help") == 0)
282 {
283 /* Print full help text*/
284 PrintMessageString(4381);
285 ConPuts(StdOut, L"\n");
286 PrintNetMessage(MSG_STATISTICS_SYNTAX);
287 PrintNetMessage(MSG_STATISTICS_HELP);
288 return 0;
289 }
290 }
291
292 if (bServer)
293 {
295 }
296 else if (bWorkstation)
297 {
299 }
300 else
301 {
302 PrintMessageString(4379);
303 ConPuts(StdOut, L"\n");
304 ConPuts(StdOut, L" Server\n");
305 ConPuts(StdOut, L" Workstation\n");
306 ConPuts(StdOut, L"\n");
307 }
308
309 if (result == 0)
311
312 return result;
313}
static INT DisplayServerStatistics(VOID)
Definition: cmdStatistics.c:14
static INT DisplayWorkstationStatistics(VOID)

◆ cmdStop()

INT cmdStop ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdStop.c.

13{
14 SC_HANDLE hManager = NULL;
15 SC_HANDLE hService = NULL;
17 DWORD dwError = ERROR_SUCCESS;
18 INT nError = 0;
19 INT i;
20
21 if (argc != 3)
22 {
24 ConPuts(StdOut, L"\n");
25 PrintNetMessage(MSG_STOP_SYNTAX);
26 return 1;
27 }
28
29 for (i = 2; i < argc; i++)
30 {
31 if (_wcsicmp(argv[i], L"/help") == 0)
32 {
34 ConPuts(StdOut, L"\n");
35 PrintNetMessage(MSG_STOP_SYNTAX);
36 PrintNetMessage(MSG_STOP_HELP);
37 return 1;
38 }
39 }
40
41 hManager = OpenSCManagerW(NULL,
44 if (hManager == NULL)
45 {
46 dwError = GetLastError();
47 nError = 1;
48 goto done;
49 }
50
51 hService = OpenServiceW(hManager,
52 argv[2],
54 if (hService == NULL)
55 {
56 dwError = GetLastError();
57 nError = 1;
58 goto done;
59 }
60
62 {
63 dwError = GetLastError();
64 nError = 1;
65 goto done;
66 }
67
68done:
69 if (hService != NULL)
70 CloseServiceHandle(hService);
71
72 if (hManager != NULL)
73 CloseServiceHandle(hManager);
74
75 if (dwError != ERROR_SUCCESS)
76 {
77 /* FIXME: Print proper error message */
78 ConPrintf(StdErr, L"Error: %lu\n", dwError);
79 }
80
81 return nError;
82}
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
#define SERVICE_STOP
Definition: winsvc.h:58
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36

Referenced by CommandShell().

◆ cmdSyntax()

INT cmdSyntax ( INT  argc,
WCHAR **  argv 
)

Definition at line 180 of file cmdHelp.c.

181{
182 PrintMessageString(4381);
183 ConPuts(StdOut, L"\n");
184 PrintNetMessage(MSG_SYNTAX_HELP);
185 return 0;
186}

◆ cmdUse()

INT cmdUse ( INT  argc,
WCHAR **  argv 
)

Definition at line 104 of file cmdUse.c.

107{
109
110 if (argc == 2)
111 {
113 if (Status == NO_ERROR)
115 else
117
118 return 0;
119 }
120 else if (argc == 3)
121 {
122 if (!ValidateDeviceName(argv[2]))
123 {
124 PrintMessageStringV(3952, L"DeviceName");
125 return 1;
126 }
127
129 if (Status == NO_ERROR)
131 else
133
134 return 0;
135 }
136
137 Delete = 0;
138 if (_wcsicmp(argv[2], L"/DELETE") == 0)
139 {
140 Delete = 3;
141 }
142 else
143 {
144 if ((argv[2][0] != '*' && argv[2][1] != 0) &&
146 {
147 PrintMessageStringV(3952, L"DeviceName");
148 return 1;
149 }
150 }
151
152 if (_wcsicmp(argv[3], L"/DELETE") == 0)
153 {
154 Delete = 2;
155 }
156
157 if (Delete != 0)
158 {
159 if (!ValidateDeviceName(argv[Delete]) || argv[Delete][0] == L'*')
160 {
161 PrintMessageStringV(3952, L"DeviceName");
162 return 1;
163 }
164
166 if (Status != NO_ERROR)
168
169 return Status;
170 }
171 else
172 {
174 NETRESOURCE lpNet;
175 WCHAR Access[256];
176 DWORD OutFlags = 0, Size = ARRAYSIZE(Access);
177
178 Len = wcslen(argv[3]);
179 if (Len < 4)
180 {
181 PrintMessageStringV(3952, L"Name");
182 return 1;
183 }
184
185 if (argv[3][0] != L'\\' || argv[3][1] != L'\\')
186 {
187 PrintMessageStringV(3952, L"Name");
188 return 1;
189 }
190
191 if (argc > 4)
192 {
193 LPWSTR Cpy;
194 Len = wcslen(argv[4]);
195 if (Len > 12)
196 {
197 Cpy = HeapAlloc(GetProcessHeap(), 0, (Len + 1) * sizeof(WCHAR));
198 if (Cpy)
199 {
200 INT i;
201 for (i = 0; i < Len; ++i)
202 Cpy[i] = towupper(argv[4][i]);
203
204 if (wcsstr(Cpy, L"/PERSISTENT:") == Cpy)
205 {
206 LPWSTR Arg = Cpy + 12;
207 if (Len == 14 && Arg[0] == 'N' && Arg[1] == 'O')
208 {
209 Persist = FALSE;
210 }
211 else if (Len == 15 && Arg[0] == 'Y' && Arg[1] == 'E' && Arg[2] == 'S')
212 {
213 Persist = TRUE;
214 }
215 else
216 {
217 HeapFree(GetProcessHeap(), 0, Cpy);
218 PrintMessageStringV(3952, L"Persistent");
219 return 1;
220 }
221 }
222 HeapFree(GetProcessHeap(), 0, Cpy);
223 }
224 }
225
226 }
227
229 lpNet.lpLocalName = (argv[2][0] != L'*') ? argv[2] : NULL;
230 lpNet.lpRemoteName = argv[3];
231 lpNet.lpProvider = NULL;
232
233 Status = WNetUseConnection(NULL, &lpNet, NULL, NULL, CONNECT_REDIRECT | (Persist ? CONNECT_UPDATE_PROFILE : 0), Access, &Size, &OutFlags);
234 if (argv[2][0] == L'*' && Status == NO_ERROR && OutFlags == CONNECT_LOCALDRIVE)
235 PrintMessageStringV(3919, argv[3], Access);
236 else if (Status != NO_ERROR)
238
239 return Status;
240 }
241}
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
static DWORD EnumerateConnections(LPCWSTR Local)
Definition: cmdUse.c:14
static VOID PrintError(DWORD Status)
Definition: cmdUse.c:68
static BOOL ValidateDeviceName(PWSTR DevName)
Definition: cmdUse.c:85
#define NO_ERROR
Definition: dderror.h:5
#define Len
Definition: deflate.h:82
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
static IPersist Persist
Definition: atl.c:503
LPSTR lpLocalName
Definition: winnetwk.h:171
LPSTR lpProvider
Definition: winnetwk.h:174
LPSTR lpRemoteName
Definition: winnetwk.h:172
DWORD dwType
Definition: winnetwk.h:168
#define towupper(c)
Definition: wctype.h:99
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define CONNECT_REDIRECT
Definition: winnetwk.h:94
#define CONNECT_UPDATE_PROFILE
Definition: winnetwk.h:87
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define CONNECT_LOCALDRIVE
Definition: winnetwk.h:95
#define WNetUseConnection
Definition: winnetwk.h:609
#define WNetCancelConnection2
Definition: winnetwk.h:607

◆ cmdUser()

INT cmdUser ( INT  argc,
WCHAR **  argv 
)

Definition at line 1148 of file cmdUser.c.

1151{
1152 INT i, j;
1153 INT result = 0;
1154 BOOL bAdd = FALSE;
1155 BOOL bDelete = FALSE;
1156#if 0
1157 BOOL bDomain = FALSE;
1158#endif
1159 BOOL bRandomPassword = FALSE;
1160 LPWSTR lpUserName = NULL;
1161 LPWSTR lpPassword = NULL;
1162 PUSER_INFO_4 pUserInfo = NULL;
1163 USER_INFO_4 UserInfo;
1164 LPWSTR pWorkstations = NULL;
1165 LPWSTR p;
1166 LPWSTR endptr;
1167 DWORD value;
1168 BOOL bPasswordAllocated = FALSE;
1169 PBYTE pLogonHours = NULL;
1170 DWORD dwUnitsPerWeek;
1172
1173 i = 2;
1174 if ((i < argc) && (argv[i][0] != L'/'))
1175 {
1176 lpUserName = argv[i];
1177// ConPrintf(StdOut, L"User: %s\n", lpUserName);
1178 i++;
1179 }
1180
1181 if ((i < argc) && (argv[i][0] != L'/'))
1182 {
1183 lpPassword = argv[i];
1184// ConPrintf(StdOut, L"Password: %s\n", lpPassword);
1185 i++;
1186 }
1187
1188 for (j = i; j < argc; j++)
1189 {
1190 if (_wcsicmp(argv[j], L"/help") == 0)
1191 {
1192 PrintNetMessage(MSG_USER_HELP);
1193 return 0;
1194 }
1195 else if (_wcsicmp(argv[j], L"/add") == 0)
1196 {
1197 bAdd = TRUE;
1198 }
1199 else if (_wcsicmp(argv[j], L"/delete") == 0)
1200 {
1201 bDelete = TRUE;
1202 }
1203 else if (_wcsicmp(argv[j], L"/domain") == 0)
1204 {
1205 ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
1206#if 0
1207 bDomain = TRUE;
1208#endif
1209 }
1210 else if (_wcsicmp(argv[j], L"/random") == 0)
1211 {
1212 bRandomPassword = TRUE;
1213 GenerateRandomPassword(&lpPassword,
1214 &bPasswordAllocated);
1215 }
1216 }
1217
1218 if (lpUserName == NULL && lpPassword == NULL)
1219 {
1222 return 0;
1223 }
1224 else if (lpUserName != NULL && lpPassword == NULL && argc == 3)
1225 {
1226 Status = DisplayUser(lpUserName);
1228 return 0;
1229 }
1230
1231 if (bAdd && bDelete)
1232 {
1233 result = 1;
1234 goto done;
1235 }
1236
1237 /* Interactive password input */
1238 if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
1239 {
1240 ReadPassword(&lpPassword,
1241 &bPasswordAllocated);
1242 }
1243
1244 if (!bAdd && !bDelete)
1245 {
1246 /* Modify the user */
1248 lpUserName,
1249 4,
1250 (LPBYTE*)&pUserInfo);
1251 if (Status != NERR_Success)
1252 {
1254 result = 1;
1255 goto done;
1256 }
1257 }
1258 else if (bAdd)
1259 {
1260 /* Add the user */
1261 ZeroMemory(&UserInfo, sizeof(USER_INFO_4));
1262
1263 UserInfo.usri4_name = lpUserName;
1264 UserInfo.usri4_password = lpPassword;
1268
1269 pUserInfo = &UserInfo;
1270 }
1271
1272 for (j = i; j < argc; j++)
1273 {
1274 if (_wcsnicmp(argv[j], L"/active:", 8) == 0)
1275 {
1276 p = &argv[i][8];
1277 if (_wcsicmp(p, L"yes") == 0)
1278 {
1279 pUserInfo->usri4_flags &= ~UF_ACCOUNTDISABLE;
1280 }
1281 else if (_wcsicmp(p, L"no") == 0)
1282 {
1283 pUserInfo->usri4_flags |= UF_ACCOUNTDISABLE;
1284 }
1285 else
1286 {
1287 PrintMessageStringV(3952, L"/ACTIVE");
1288 result = 1;
1289 goto done;
1290 }
1291 }
1292 else if (_wcsnicmp(argv[j], L"/comment:", 9) == 0)
1293 {
1294 pUserInfo->usri4_comment = &argv[j][9];
1295 }
1296 else if (_wcsnicmp(argv[j], L"/countrycode:", 13) == 0)
1297 {
1298 p = &argv[i][13];
1299 value = wcstoul(p, &endptr, 10);
1300 if (*endptr != 0)
1301 {
1302 PrintMessageStringV(3952, L"/COUNTRYCODE");
1303 result = 1;
1304 goto done;
1305 }
1306
1307 /* Verify the country code */
1309 pUserInfo->usri4_country_code = value;
1310 }
1311 else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
1312 {
1313 p = &argv[i][9];
1314 if (_wcsicmp(p, L"never") == 0)
1315 {
1316 pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
1317 }
1318 else if (!ParseDate(p, &pUserInfo->usri4_acct_expires))
1319 {
1320 PrintMessageStringV(3952, L"/EXPIRES");
1321 result = 1;
1322 goto done;
1323 }
1324 }
1325 else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
1326 {
1327 pUserInfo->usri4_full_name = &argv[j][10];
1328 }
1329 else if (_wcsnicmp(argv[j], L"/homedir:", 9) == 0)
1330 {
1331 pUserInfo->usri4_home_dir = &argv[j][9];
1332 }
1333 else if (_wcsnicmp(argv[j], L"/passwordchg:", 13) == 0)
1334 {
1335 p = &argv[i][13];
1336 if (_wcsicmp(p, L"yes") == 0)
1337 {
1338 pUserInfo->usri4_flags &= ~UF_PASSWD_CANT_CHANGE;
1339 }
1340 else if (_wcsicmp(p, L"no") == 0)
1341 {
1342 pUserInfo->usri4_flags |= UF_PASSWD_CANT_CHANGE;
1343 }
1344 else
1345 {
1346 PrintMessageStringV(3952, L"/PASSWORDCHG");
1347 result = 1;
1348 goto done;
1349 }
1350 }
1351 else if (_wcsnicmp(argv[j], L"/passwordreq:", 13) == 0)
1352 {
1353 p = &argv[i][13];
1354 if (_wcsicmp(p, L"yes") == 0)
1355 {
1356 pUserInfo->usri4_flags &= ~UF_PASSWD_NOTREQD;
1357 }
1358 else if (_wcsicmp(p, L"no") == 0)
1359 {
1360 pUserInfo->usri4_flags |= UF_PASSWD_NOTREQD;
1361 }
1362 else
1363 {
1364 PrintMessageStringV(3952, L"/PASSWORDREQ");
1365 result = 1;
1366 goto done;
1367 }
1368 }
1369 else if (_wcsnicmp(argv[j], L"/profilepath:", 13) == 0)
1370 {
1371 pUserInfo->usri4_profile = &argv[j][13];
1372 }
1373 else if (_wcsnicmp(argv[j], L"/scriptpath:", 12) == 0)
1374 {
1375 pUserInfo->usri4_script_path = &argv[j][12];
1376 }
1377 else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
1378 {
1380 &pLogonHours,
1381 &dwUnitsPerWeek);
1382 if (Status == ERROR_SUCCESS)
1383 {
1384 pUserInfo->usri4_logon_hours = pLogonHours;
1385 pUserInfo->usri4_units_per_week = dwUnitsPerWeek;
1386 }
1387 else
1388 {
1390 goto done;
1391 }
1392 }
1393 else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
1394 {
1395 pUserInfo->usri4_usr_comment = &argv[j][13];
1396 }
1397 else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
1398 {
1399 p = &argv[i][14];
1400 if (wcscmp(p, L"*") == 0 || wcscmp(p, L"") == 0)
1401 {
1402 pUserInfo->usri4_workstations = NULL;
1403 }
1404 else
1405 {
1406 Status = BuildWorkstationsList(&pWorkstations, p);
1407 if (Status == NERR_Success)
1408 {
1409 pUserInfo->usri4_workstations = pWorkstations;
1410 }
1411 else
1412 {
1414 result = 1;
1415 goto done;
1416 }
1417 }
1418 }
1419 }
1420
1421 if (!bAdd && !bDelete)
1422 {
1423 /* Modify the user */
1425 lpUserName,
1426 4,
1427 (LPBYTE)pUserInfo,
1428 NULL);
1429 }
1430 else if (bAdd)
1431 {
1432 /* Add the user */
1434 4,
1435 (LPBYTE)pUserInfo,
1436 NULL);
1437 }
1438 else if (bDelete)
1439 {
1440 /* Delete the user */
1442 lpUserName);
1443 }
1444
1446
1447 if (Status == NERR_Success &&
1448 lpPassword != NULL &&
1449 bRandomPassword == TRUE)
1450 {
1451 PrintMessageStringV(3968, lpUserName, lpPassword);
1452 }
1453
1454done:
1455 if (pLogonHours != NULL)
1456 HeapFree(GetProcessHeap(), 0, pLogonHours);
1457
1458 if (pWorkstations != NULL)
1459 HeapFree(GetProcessHeap(), 0, pWorkstations);
1460
1461 if ((bPasswordAllocated == TRUE) && (lpPassword != NULL))
1462 HeapFree(GetProcessHeap(), 0, lpPassword);
1463
1464 if (!bAdd && !bDelete && pUserInfo != NULL)
1465 NetApiBufferFree(pUserInfo);
1466
1467 if (result != 0)
1468 {
1469 PrintMessageString(4381);
1470 ConPuts(StdOut, L"\n");
1471 PrintNetMessage(MSG_USER_SYNTAX);
1472 }
1473
1474 return result;
1475}
DWORD TranslateAppMessage(DWORD dwMessage)
Definition: main.c:79
static BOOL ParseDate(PWSTR s, PULONG pSeconds)
Definition: cmdUser.c:746
static VOID GenerateRandomPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:582
static NET_API_STATUS BuildWorkstationsList(_Out_ PWSTR *pWorkstationsList, _In_ PWSTR pRaw)
Definition: cmdUser.c:611
static BOOL GetCountryFromCountryCode(_In_ DWORD dwCountryCode, _In_ DWORD dwCountryLength, _Out_ PWSTR szCountryBuffer)
Definition: cmdUser.c:199
static VOID ReadPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:536
static DWORD ParseLogonHours(PWSTR pszParams, PBYTE *ppLogonBitmap, PDWORD pdwUnitsPerWeek)
Definition: cmdUser.c:932
static NET_API_STATUS EnumerateUsers(VOID)
Definition: cmdUser.c:65
static NET_API_STATUS DisplayUser(LPWSTR lpUserName)
Definition: cmdUser.c:344
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
NET_API_STATUS WINAPI NetUserSetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: user.c:3975
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
#define UF_PASSWD_CANT_CHANGE
Definition: lmaccess.h:28
#define UF_PASSWD_NOTREQD
Definition: lmaccess.h:27
#define UF_NORMAL_ACCOUNT
Definition: lmaccess.h:30
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LPWSTR usri4_workstations
Definition: lmaccess.h:282
DWORD usri4_flags
Definition: lmaccess.h:276
LPWSTR usri4_comment
Definition: lmaccess.h:275
DWORD usri4_primary_group_id
Definition: lmaccess.h:295
DWORD usri4_units_per_week
Definition: lmaccess.h:287
DWORD usri4_acct_expires
Definition: lmaccess.h:285
LPWSTR usri4_profile
Definition: lmaccess.h:296
LPWSTR usri4_usr_comment
Definition: lmaccess.h:280
LPWSTR usri4_name
Definition: lmaccess.h:270
LPWSTR usri4_password
Definition: lmaccess.h:271
DWORD usri4_country_code
Definition: lmaccess.h:292
LPWSTR usri4_home_dir
Definition: lmaccess.h:274
PBYTE usri4_logon_hours
Definition: lmaccess.h:288
LPWSTR usri4_full_name
Definition: lmaccess.h:279
LPWSTR usri4_script_path
Definition: lmaccess.h:277
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:640

◆ help()

◆ PrintErrorMessage()

VOID PrintErrorMessage ( DWORD  dwError)

Definition at line 123 of file common.c.

124{
125 TCHAR * String;
126
127 /* Try to get textual error */
129 NULL, Error, 0, (TCHAR *)&String, 0, NULL) != 0)
130 {
131 /* And print it */
132 _ftprintf(stderr, _T("Error: %s\n"), String);
134 }
135 else
136 {
137 /* Otherwise, just print the error number */
138 _ftprintf(stderr, _T("Error: %d\n"), Error);
139 }
140
141 return Error;
142}
BOOL Error
Definition: chkdsk.c:66
#define stderr
Definition: stdio.h:100
#define _ftprintf
Definition: tchar.h:518
#define _T(x)
Definition: vfdio.h:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
char TCHAR
Definition: xmlstorage.h:189

Referenced by OpenVolume().

◆ PrintMessageString()

◆ PrintMessageStringV()

VOID PrintMessageStringV ( DWORD  dwMessage,
  ... 
)

Definition at line 93 of file main.c.

96{
99
100 va_start(args, dwMessage);
101
104 dwMessage,
106 (LPWSTR)&pBuffer,
107 0,
108 &args);
109 va_end(args);
110
111 if (pBuffer)
112 {
115 pBuffer = NULL;
116 }
117}
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: match.c:390

Referenced by cmdAccounts(), cmdConfig(), cmdUse(), cmdUser(), DisplayServerStatistics(), DisplayWorkstationStatistics(), EnumerateGroups(), EnumerateLocalGroups(), EnumerateUsers(), and PrintError().

◆ PrintNetMessage()

VOID PrintNetMessage ( DWORD  dwMessage)

◆ PrintPaddedMessageString()

VOID PrintPaddedMessageString ( DWORD  dwMessage,
INT  nPaddedLength 
)

Definition at line 143 of file main.c.

146{
149
153 dwMessage,
155 (LPWSTR)&pBuffer,
156 0,
157 NULL);
158 if (pBuffer)
159 {
162 pBuffer = NULL;
163 }
164
165 if (dwLength < (DWORD)nPaddedLength)
166 PrintPadding(L' ', (DWORD)nPaddedLength - dwLength);
167}
VOID PrintPadding(WCHAR chr, INT nPaddedLength)
Definition: main.c:63
static DWORD DWORD * dwLength
Definition: fusion.c:86

Referenced by cmdAccounts(), DisplayGroup(), DisplayLocalGroup(), DisplayServerConfig(), DisplayServerStatistics(), DisplayShare(), DisplayUser(), DisplayWorkstationConfig(), and DisplayWorkstationStatistics().

◆ PrintPaddedResourceString()

VOID PrintPaddedResourceString ( UINT  uID,
INT  nPaddedLength 
)

Definition at line 50 of file main.c.

53{
55
57 if (nLength < nPaddedLength)
58 PrintPadding(L' ', nPaddedLength - nLength);
59}
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
_In_ DWORD nLength
Definition: wincon.h:473

◆ PrintPadding()

VOID PrintPadding ( WCHAR  chr,
INT  nPaddedLength 
)

Definition at line 63 of file main.c.

66{
67 INT i;
68 WCHAR szMsgBuffer[MAX_BUFFER_SIZE];
69
70 for (i = 0; i < nPaddedLength; i++)
71 szMsgBuffer[i] = chr;
72 szMsgBuffer[nPaddedLength] = UNICODE_NULL;
73
74 ConPuts(StdOut, szMsgBuffer);
75}
#define MAX_BUFFER_SIZE
Definition: main.c:12

Referenced by DisplayGroup(), DisplayLocalGroup(), DisplayUser(), EnumerateGroups(), EnumerateLocalGroups(), EnumerateShares(), EnumerateUsers(), EnumSessions(), PrintLogonHours(), PrintPaddedMessageString(), and PrintPaddedResourceString().

◆ ReadFromConsole()

VOID ReadFromConsole ( LPWSTR  lpInput,
DWORD  dwLength,
BOOL  bEcho 
)

Definition at line 264 of file main.c.

268{
269 DWORD dwOldMode;
270 DWORD dwRead = 0;
272 LPWSTR p;
273 PCHAR pBuf;
274
275 pBuf = HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
276 ZeroMemory(lpInput, dwLength * sizeof(WCHAR));
278 GetConsoleMode(hFile, &dwOldMode);
279
281
282 ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
283
284 MultiByteToWideChar(CP_OEMCP, 0, pBuf, dwRead, lpInput, dwLength - 1);
285 HeapFree(GetProcessHeap(), 0, pBuf);
286
287 for (p = lpInput; *p; p++)
288 {
289 if (*p == L'\x0d')
290 {
291 *p = L'\0';
292 break;
293 }
294 }
295
296 SetConsoleMode(hFile, dwOldMode);
297}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL bEcho
Definition: batch.c:73
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
_In_ HANDLE hFile
Definition: mswsock.h:90
char * PCHAR
Definition: typedefs.h:51
#define STD_INPUT_HANDLE
Definition: winbase.h:293
#define ENABLE_ECHO_INPUT
Definition: wincon.h:80
#define ENABLE_LINE_INPUT
Definition: wincon.h:79
#define CP_OEMCP
Definition: winnls.h:233

Referenced by ReadPassword().

◆ TranslateAppMessage()

DWORD TranslateAppMessage ( DWORD  dwMessage)

Definition at line 79 of file main.c.

81{
82 switch (dwMessage)
83 {
84 case NERR_Success:
85 return 3500; // APPERR_3500
86 case ERROR_MORE_DATA:
87 return 3513; // APPERR_3513
88 }
89 return dwMessage;
90}
#define ERROR_MORE_DATA
Definition: dderror.h:13

Referenced by cmdUser().

◆ unimplemented()

INT unimplemented ( INT  argc,
WCHAR **  argv 
)

Definition at line 352 of file main.c.

353{
354 ConPuts(StdOut, L"This command is not implemented yet\n");
355 return 1;
356}

Variable Documentation

◆ hModuleNetMsg