2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdUser.c
7 * PROGRAMMERS: Eric Kohl
13 typedef struct _COUNTY_TABLE
17 } COUNTRY_TABLE
, *PCOUNTRY_TABLE
;
20 static WCHAR szPasswordChars
[] = L
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%_-+:";
21 static COUNTRY_TABLE CountryTable
[] =
22 { { 0, 5080}, // System Default
23 { 1, 5081}, // United States
24 { 2, 5082}, // Canada (French)
25 { 3, 5083}, // Latin America
26 { 31, 5084}, // Netherlands
27 { 32, 5085}, // Belgium
28 { 33, 5086}, // France
31 { 41, 5088}, // Switzerland
32 { 44, 5089}, // United Kingdom
33 { 45, 5091}, // Denmark
34 { 46, 5092}, // Sweden
35 { 47, 5093}, // Norway
36 { 49, 5094}, // Germany
37 { 61, 5095}, // Australia
40 { 86, 5098}, // China (PRC)
41 { 88, 5099}, // Taiwan
43 {351, 5101}, // Portugal
44 {358, 5102}, // Finland
45 {785, 5103}, // Arabic
46 {972, 5104} }; // Hebrew
51 CompareInfo(const void *a
, const void *b
)
53 return _wcsicmp(((PUSER_INFO_0
)a
)->usri0_name
,
54 ((PUSER_INFO_0
)b
)->usri0_name
);
62 PUSER_INFO_0 pBuffer
= NULL
;
63 PSERVER_INFO_100 pServer
= NULL
;
64 DWORD dwRead
= 0, dwTotal
= 0;
66 DWORD ResumeHandle
= 0;
67 NET_API_STATUS Status
;
69 Status
= NetServerGetInfo(NULL
,
72 if (Status
!= NERR_Success
)
75 ConPuts(StdOut
, L
"\n");
76 PrintMessageStringV(4410, pServer
->sv100_name
);
77 ConPuts(StdOut
, L
"\n");
78 PrintPadding(L
'-', 79);
79 ConPuts(StdOut
, L
"\n");
81 NetApiBufferFree(pServer
);
85 Status
= NetUserEnum(NULL
,
93 if ((Status
!= NERR_Success
) && (Status
!= ERROR_MORE_DATA
))
101 for (i
= 0; i
< dwRead
; i
++)
103 if (pBuffer
[i
].usri0_name
)
104 ConPrintf(StdOut
, L
"%s\n", pBuffer
[i
].usri0_name
);
107 NetApiBufferFree(pBuffer
);
110 while (Status
== ERROR_MORE_DATA
);
118 PrintDateTime(DWORD dwSeconds
)
122 SYSTEMTIME SystemTime
;
123 WCHAR DateBuffer
[80];
124 WCHAR TimeBuffer
[80];
126 RtlSecondsSince1970ToTime(dwSeconds
, &Time
);
127 FileTime
.dwLowDateTime
= Time
.u
.LowPart
;
128 FileTime
.dwHighDateTime
= Time
.u
.HighPart
;
129 FileTimeToLocalFileTime(&FileTime
, &FileTime
);
130 FileTimeToSystemTime(&FileTime
, &SystemTime
);
132 GetDateFormatW(LOCALE_USER_DEFAULT
,
139 GetTimeFormatW(LOCALE_USER_DEFAULT
,
146 ConPrintf(StdOut
, L
"%s %s", DateBuffer
, TimeBuffer
);
152 GetTimeInSeconds(VOID
)
158 GetSystemTimeAsFileTime(&FileTime
);
159 Time
.u
.LowPart
= FileTime
.dwLowDateTime
;
160 Time
.u
.HighPart
= FileTime
.dwHighDateTime
;
161 RtlTimeToSecondsSince1970(&Time
, &dwSeconds
);
169 GetCountryFromCountryCode(
170 _In_ DWORD dwCountryCode
,
171 _In_ DWORD dwCountryLength
,
172 _Out_ PWSTR szCountryBuffer
)
176 for (i
= 0; i
< ARRAYSIZE(CountryTable
); i
++)
178 if (CountryTable
[i
].dwCountryCode
== dwCountryCode
)
180 if (szCountryBuffer
!= NULL
&& dwCountryLength
> 0)
182 FormatMessageW(FORMAT_MESSAGE_FROM_HMODULE
| FORMAT_MESSAGE_IGNORE_INSERTS
,
184 CountryTable
[i
].dwMessageId
,
201 DisplayUser(LPWSTR lpUserName
)
203 PUSER_MODALS_INFO_0 pUserModals
= NULL
;
204 PUSER_INFO_4 pUserInfo
= NULL
;
205 PLOCALGROUP_USERS_INFO_0 pLocalGroupInfo
= NULL
;
206 PGROUP_USERS_INFO_0 pGroupInfo
= NULL
;
207 DWORD dwLocalGroupRead
, dwLocalGroupTotal
;
208 DWORD dwGroupRead
, dwGroupTotal
;
212 INT nPaddedLength
= 36;
213 NET_API_STATUS Status
;
215 /* Modify the user */
216 Status
= NetUserGetInfo(NULL
,
219 (LPBYTE
*)&pUserInfo
);
220 if (Status
!= NERR_Success
)
223 Status
= NetUserModalsGet(NULL
,
225 (LPBYTE
*)&pUserModals
);
226 if (Status
!= NERR_Success
)
229 Status
= NetUserGetLocalGroups(NULL
,
233 (LPBYTE
*)&pLocalGroupInfo
,
234 MAX_PREFERRED_LENGTH
,
237 if (Status
!= NERR_Success
)
240 Status
= NetUserGetGroups(NULL
,
243 (LPBYTE
*)&pGroupInfo
,
244 MAX_PREFERRED_LENGTH
,
247 if (Status
!= NERR_Success
)
250 PrintPaddedMessageString(4411, nPaddedLength
);
251 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_name
);
253 PrintPaddedMessageString(4412, nPaddedLength
);
254 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_full_name
);
256 PrintPaddedMessageString(4413, nPaddedLength
);
257 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_comment
);
259 PrintPaddedMessageString(4414, nPaddedLength
);
260 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_usr_comment
);
262 PrintPaddedMessageString(4416, nPaddedLength
);
263 GetCountryFromCountryCode(pUserInfo
->usri4_country_code
,
264 ARRAYSIZE(szCountry
), szCountry
);
265 ConPrintf(StdOut
, L
"%03ld (%s)\n", pUserInfo
->usri4_country_code
, szCountry
);
267 PrintPaddedMessageString(4419, nPaddedLength
);
268 if (pUserInfo
->usri4_flags
& UF_ACCOUNTDISABLE
)
269 ConResPuts(StdOut
, IDS_GENERIC_NO
);
270 else if (pUserInfo
->usri4_flags
& UF_LOCKOUT
)
271 PrintMessageString(4440);
273 ConResPuts(StdOut
, IDS_GENERIC_YES
);
274 ConPuts(StdOut
, L
"\n");
276 PrintPaddedMessageString(4420, nPaddedLength
);
277 if (pUserInfo
->usri4_acct_expires
== TIMEQ_FOREVER
)
278 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
280 PrintDateTime(pUserInfo
->usri4_acct_expires
);
281 ConPuts(StdOut
, L
"\n\n");
283 PrintPaddedMessageString(4421, nPaddedLength
);
284 dwLastSet
= GetTimeInSeconds() - pUserInfo
->usri4_password_age
;
285 PrintDateTime(dwLastSet
);
286 ConPuts(StdOut
, L
"\n");
288 PrintPaddedMessageString(4422, nPaddedLength
);
289 if ((pUserInfo
->usri4_flags
& UF_DONT_EXPIRE_PASSWD
) || pUserModals
->usrmod0_max_passwd_age
== TIMEQ_FOREVER
)
290 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
292 PrintDateTime(dwLastSet
+ pUserModals
->usrmod0_max_passwd_age
);
293 ConPuts(StdOut
, L
"\n");
295 PrintPaddedMessageString(4423, nPaddedLength
);
296 PrintDateTime(dwLastSet
+ pUserModals
->usrmod0_min_passwd_age
);
297 ConPuts(StdOut
, L
"\n");
299 PrintPaddedMessageString(4437, nPaddedLength
);
300 ConResPuts(StdOut
, (pUserInfo
->usri4_flags
& UF_PASSWD_NOTREQD
) ? IDS_GENERIC_NO
: IDS_GENERIC_YES
);
301 ConPuts(StdOut
, L
"\n");
303 PrintPaddedMessageString(4438, nPaddedLength
);
304 ConResPuts(StdOut
, (pUserInfo
->usri4_flags
& UF_PASSWD_CANT_CHANGE
) ? IDS_GENERIC_NO
: IDS_GENERIC_YES
);
305 ConPuts(StdOut
, L
"\n\n");
307 PrintPaddedMessageString(4424, nPaddedLength
);
308 if (pUserInfo
->usri4_workstations
== NULL
|| wcslen(pUserInfo
->usri4_workstations
) == 0)
309 ConResPuts(StdOut
, IDS_GENERIC_ALL
);
311 ConPrintf(StdOut
, L
"%s", pUserInfo
->usri4_workstations
);
312 ConPuts(StdOut
, L
"\n");
314 PrintPaddedMessageString(4429, nPaddedLength
);
315 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_script_path
);
317 PrintPaddedMessageString(4439, nPaddedLength
);
318 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_profile
);
320 PrintPaddedMessageString(4436, nPaddedLength
);
321 ConPrintf(StdOut
, L
"%s\n", pUserInfo
->usri4_home_dir
);
323 PrintPaddedMessageString(4430, nPaddedLength
);
324 if (pUserInfo
->usri4_last_logon
== 0)
325 ConResPuts(StdOut
, IDS_GENERIC_NEVER
);
327 PrintDateTime(pUserInfo
->usri4_last_logon
);
328 ConPuts(StdOut
, L
"\n\n");
330 PrintPaddedMessageString(4432, nPaddedLength
);
331 if (pUserInfo
->usri4_logon_hours
== NULL
)
332 ConResPuts(StdOut
, IDS_GENERIC_ALL
);
333 ConPuts(StdOut
, L
"\n\n");
335 ConPuts(StdOut
, L
"\n");
336 PrintPaddedMessageString(4427, nPaddedLength
);
337 if (dwLocalGroupTotal
!= 0 && pLocalGroupInfo
!= NULL
)
339 for (i
= 0; i
< dwLocalGroupTotal
; i
++)
342 PrintPadding(L
' ', nPaddedLength
);
343 ConPrintf(StdOut
, L
"*%s\n", pLocalGroupInfo
[i
].lgrui0_name
);
348 ConPuts(StdOut
, L
"\n");
351 PrintPaddedMessageString(4431, nPaddedLength
);
352 if (dwGroupTotal
!= 0 && pGroupInfo
!= NULL
)
354 for (i
= 0; i
< dwGroupTotal
; i
++)
357 PrintPadding(L
' ', nPaddedLength
);
358 ConPrintf(StdOut
, L
"*%s\n", pGroupInfo
[i
].grui0_name
);
363 ConPuts(StdOut
, L
"\n");
367 if (pGroupInfo
!= NULL
)
368 NetApiBufferFree(pGroupInfo
);
370 if (pLocalGroupInfo
!= NULL
)
371 NetApiBufferFree(pLocalGroupInfo
);
373 if (pUserModals
!= NULL
)
374 NetApiBufferFree(pUserModals
);
376 if (pUserInfo
!= NULL
)
377 NetApiBufferFree(pUserInfo
);
389 WCHAR szPassword1
[PWLEN
+ 1];
390 WCHAR szPassword2
[PWLEN
+ 1];
393 *lpAllocated
= FALSE
;
397 PrintMessageString(4358);
398 ReadFromConsole(szPassword1
, PWLEN
+ 1, FALSE
);
399 ConPuts(StdOut
, L
"\n");
401 PrintMessageString(4361);
402 ReadFromConsole(szPassword2
, PWLEN
+ 1, FALSE
);
403 ConPuts(StdOut
, L
"\n");
405 if (wcslen(szPassword1
) == wcslen(szPassword2
) &&
406 wcscmp(szPassword1
, szPassword2
) == 0)
408 ptr
= HeapAlloc(GetProcessHeap(),
410 (wcslen(szPassword1
) + 1) * sizeof(WCHAR
));
413 wcscpy(ptr
, szPassword1
);
421 ConPuts(StdOut
, L
"\n");
422 PrintMessageString(3728);
431 GenerateRandomPassword(
435 LPWSTR pPassword
= NULL
;
436 INT nCharsLen
, i
, nLength
= 8;
438 srand(GetTickCount());
440 pPassword
= HeapAlloc(GetProcessHeap(),
442 (nLength
+ 1) * sizeof(WCHAR
));
443 if (pPassword
== NULL
)
446 nCharsLen
= wcslen(szPasswordChars
);
448 for (i
= 0; i
< nLength
; i
++)
450 pPassword
[i
] = szPasswordChars
[rand() % nCharsLen
];
453 *lpPassword
= pPassword
;
460 BuildWorkstationsList(
461 _Out_ PWSTR
*pWorkstationsList
,
464 BOOL isLastSep
, isSep
;
472 /* Check for invalid characters in the raw string */
473 if (wcspbrk(pRaw
, L
"/[]=?\\+:.") != NULL
)
476 /* Count the number of workstations in the list and
477 * the required buffer size */
480 nRawLength
= wcslen(pRaw
);
481 for (i
= 0; i
< nRawLength
; i
++)
484 if (c
== L
',' || c
== L
';')
489 if ((isLastSep
== FALSE
) && (i
!= 0) && (i
!= nRawLength
- 1))
496 if (isLastSep
== TRUE
|| (isLastSep
== FALSE
&& i
== 0))
506 /* Leave, if there are no workstations in the list */
509 pWorkstationsList
= NULL
;
513 /* Fail if there are more than eight workstations in the list */
517 /* Allocate the buffer for the clean workstation list */
518 pList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nLength
* sizeof(WCHAR
));
520 return ERROR_NOT_ENOUGH_MEMORY
;
522 /* Build the clean workstation list */
525 nRawLength
= wcslen(pRaw
);
526 for (i
= 0, j
= 0; i
< nRawLength
; i
++)
529 if (c
== L
',' || c
== L
';')
534 if ((isLastSep
== FALSE
) && (i
!= 0) && (i
!= nRawLength
- 1))
545 if (isLastSep
== TRUE
|| (isLastSep
== FALSE
&& i
== 0))
553 *pWorkstationsList
= pList
;
568 while (iswdigit(**s
))
570 *pwValue
= *pwValue
* 10 + **s
- L
'0';
583 if (**s
== L
'/' || **s
== L
'.')
599 SYSTEMTIME SystemTime
= {0};
600 FILETIME LocalFileTime
, FileTime
;
608 GetLocaleInfoW(LOCALE_USER_DEFAULT
,
617 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
619 if (!ReadSeparator(&p
))
621 if (!ReadNumber(&p
, &SystemTime
.wDay
))
623 if (!ReadSeparator(&p
))
625 if (!ReadNumber(&p
, &SystemTime
.wYear
))
630 if (!ReadNumber(&p
, &SystemTime
.wDay
))
632 if (!ReadSeparator(&p
))
634 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
636 if (!ReadSeparator(&p
))
638 if (!ReadNumber(&p
, &SystemTime
.wYear
))
643 if (!ReadNumber(&p
, &SystemTime
.wYear
))
645 if (!ReadSeparator(&p
))
647 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
649 if (!ReadSeparator(&p
))
651 if (!ReadNumber(&p
, &SystemTime
.wDay
))
656 /* if only entered two digits: */
657 /* assume 2000's if value less than 80 */
658 /* assume 1900's if value greater or equal 80 */
659 if (SystemTime
.wYear
<= 99)
661 if (SystemTime
.wYear
>= 80)
662 SystemTime
.wYear
+= 1900;
664 SystemTime
.wYear
+= 2000;
667 if (!SystemTimeToFileTime(&SystemTime
, &LocalFileTime
))
670 if (!LocalFileTimeToFileTime(&LocalFileTime
, &FileTime
))
673 Time
.u
.LowPart
= FileTime
.dwLowDateTime
;
674 Time
.u
.HighPart
= FileTime
.dwHighDateTime
;
676 if (!RtlTimeToSecondsSince1970(&Time
, pSeconds
))
691 BOOL bDelete
= FALSE
;
693 BOOL bDomain
= FALSE
;
695 BOOL bRandomPassword
= FALSE
;
696 LPWSTR lpUserName
= NULL
;
697 LPWSTR lpPassword
= NULL
;
698 PUSER_INFO_4 pUserInfo
= NULL
;
699 USER_INFO_4 UserInfo
;
700 LPWSTR pWorkstations
= NULL
;
704 BOOL bPasswordAllocated
= FALSE
;
705 NET_API_STATUS Status
;
708 if ((i
< argc
) && (argv
[i
][0] != L
'/'))
710 lpUserName
= argv
[i
];
711 // ConPrintf(StdOut, L"User: %s\n", lpUserName);
715 if ((i
< argc
) && (argv
[i
][0] != L
'/'))
717 lpPassword
= argv
[i
];
718 // ConPrintf(StdOut, L"Password: %s\n", lpPassword);
722 for (j
= i
; j
< argc
; j
++)
724 if (_wcsicmp(argv
[j
], L
"/help") == 0)
726 PrintNetMessage(MSG_USER_HELP
);
729 else if (_wcsicmp(argv
[j
], L
"/add") == 0)
733 else if (_wcsicmp(argv
[j
], L
"/delete") == 0)
737 else if (_wcsicmp(argv
[j
], L
"/domain") == 0)
739 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/DOMAIN");
744 else if (_wcsicmp(argv
[j
], L
"/random") == 0)
746 bRandomPassword
= TRUE
;
747 GenerateRandomPassword(&lpPassword
,
748 &bPasswordAllocated
);
752 if (lpUserName
== NULL
&& lpPassword
== NULL
)
754 Status
= EnumerateUsers();
755 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
758 else if (lpUserName
!= NULL
&& lpPassword
== NULL
)
760 Status
= DisplayUser(lpUserName
);
761 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
771 /* Interactive password input */
772 if (lpPassword
!= NULL
&& wcscmp(lpPassword
, L
"*") == 0)
774 ReadPassword(&lpPassword
,
775 &bPasswordAllocated
);
778 if (!bAdd
&& !bDelete
)
780 /* Modify the user */
781 Status
= NetUserGetInfo(NULL
,
784 (LPBYTE
*)&pUserInfo
);
785 if (Status
!= NERR_Success
)
787 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
792 else if (bAdd
&& !bDelete
)
795 ZeroMemory(&UserInfo
, sizeof(USER_INFO_4
));
797 UserInfo
.usri4_name
= lpUserName
;
798 UserInfo
.usri4_password
= lpPassword
;
799 UserInfo
.usri4_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
;
800 UserInfo
.usri4_acct_expires
= TIMEQ_FOREVER
;
801 UserInfo
.usri4_primary_group_id
= DOMAIN_GROUP_RID_USERS
;
803 pUserInfo
= &UserInfo
;
806 for (j
= i
; j
< argc
; j
++)
808 if (_wcsnicmp(argv
[j
], L
"/active:", 8) == 0)
811 if (_wcsicmp(p
, L
"yes") == 0)
813 pUserInfo
->usri4_flags
&= ~UF_ACCOUNTDISABLE
;
815 else if (_wcsicmp(p
, L
"no") == 0)
817 pUserInfo
->usri4_flags
|= UF_ACCOUNTDISABLE
;
821 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/ACTIVE");
826 else if (_wcsnicmp(argv
[j
], L
"/comment:", 9) == 0)
828 pUserInfo
->usri4_comment
= &argv
[j
][9];
830 else if (_wcsnicmp(argv
[j
], L
"/countrycode:", 13) == 0)
833 value
= wcstoul(p
, &endptr
, 10);
836 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/COUNTRYCODE");
841 /* Verify the country code */
842 if (GetCountryFromCountryCode(value
, 0, NULL
))
843 pUserInfo
->usri4_country_code
= value
;
845 else if (_wcsnicmp(argv
[j
], L
"/expires:", 9) == 0)
848 if (_wcsicmp(p
, L
"never") == 0)
850 pUserInfo
->usri4_acct_expires
= TIMEQ_FOREVER
;
852 else if (!ParseDate(p
, &pUserInfo
->usri4_acct_expires
))
854 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/EXPIRES");
859 else if (_wcsnicmp(argv
[j
], L
"/fullname:", 10) == 0)
861 pUserInfo
->usri4_full_name
= &argv
[j
][10];
863 else if (_wcsnicmp(argv
[j
], L
"/homedir:", 9) == 0)
865 pUserInfo
->usri4_home_dir
= &argv
[j
][9];
867 else if (_wcsnicmp(argv
[j
], L
"/passwordchg:", 13) == 0)
870 if (_wcsicmp(p
, L
"yes") == 0)
872 pUserInfo
->usri4_flags
&= ~UF_PASSWD_CANT_CHANGE
;
874 else if (_wcsicmp(p
, L
"no") == 0)
876 pUserInfo
->usri4_flags
|= UF_PASSWD_CANT_CHANGE
;
880 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/PASSWORDCHG");
885 else if (_wcsnicmp(argv
[j
], L
"/passwordreq:", 13) == 0)
888 if (_wcsicmp(p
, L
"yes") == 0)
890 pUserInfo
->usri4_flags
&= ~UF_PASSWD_NOTREQD
;
892 else if (_wcsicmp(p
, L
"no") == 0)
894 pUserInfo
->usri4_flags
|= UF_PASSWD_NOTREQD
;
898 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/PASSWORDREQ");
903 else if (_wcsnicmp(argv
[j
], L
"/profilepath:", 13) == 0)
905 pUserInfo
->usri4_profile
= &argv
[j
][13];
907 else if (_wcsnicmp(argv
[j
], L
"/scriptpath:", 12) == 0)
909 pUserInfo
->usri4_script_path
= &argv
[j
][12];
911 else if (_wcsnicmp(argv
[j
], L
"/times:", 7) == 0)
914 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/TIMES");
916 else if (_wcsnicmp(argv
[j
], L
"/usercomment:", 13) == 0)
918 pUserInfo
->usri4_usr_comment
= &argv
[j
][13];
920 else if (_wcsnicmp(argv
[j
], L
"/workstations:", 14) == 0)
923 if (wcscmp(p
, L
"*") == 0 || wcscmp(p
, L
"") == 0)
925 pUserInfo
->usri4_workstations
= NULL
;
929 Status
= BuildWorkstationsList(&pWorkstations
, p
);
930 if (Status
== NERR_Success
)
932 pUserInfo
->usri4_workstations
= pWorkstations
;
936 ConPrintf(StdOut
, L
"Status %lu\n\n", Status
);
944 if (!bAdd
&& !bDelete
)
946 /* Modify the user */
947 Status
= NetUserSetInfo(NULL
,
952 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
954 else if (bAdd
&& !bDelete
)
957 Status
= NetUserAdd(NULL
,
961 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
963 else if (!bAdd
&& bDelete
)
965 /* Delete the user */
966 Status
= NetUserDel(NULL
,
968 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
971 if (Status
== NERR_Success
&&
972 lpPassword
!= NULL
&&
973 bRandomPassword
== TRUE
)
975 PrintMessageStringV(3968, lpUserName
, lpPassword
);
979 if (pWorkstations
!= NULL
)
980 HeapFree(GetProcessHeap(), 0, pWorkstations
);
982 if ((bPasswordAllocated
== TRUE
) && (lpPassword
!= NULL
))
983 HeapFree(GetProcessHeap(), 0, lpPassword
);
985 if (!bAdd
&& !bDelete
&& pUserInfo
!= NULL
)
986 NetApiBufferFree(pUserInfo
);
990 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
991 PrintNetMessage(MSG_USER_SYNTAX
);