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 ConResPuts(StdOut
, IDS_USER_ENTER_PASSWORD1
);
398 ReadFromConsole(szPassword1
, PWLEN
+ 1, FALSE
);
399 ConPuts(StdOut
, L
"\n");
401 ConResPuts(StdOut
, IDS_USER_ENTER_PASSWORD2
);
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 ConResPuts(StdOut
, IDS_USER_NO_PASSWORD_MATCH
);
423 ConPuts(StdOut
, L
"\n");
432 GenerateRandomPassword(
436 LPWSTR pPassword
= NULL
;
437 INT nCharsLen
, i
, nLength
= 8;
439 srand(GetTickCount());
441 pPassword
= HeapAlloc(GetProcessHeap(),
443 (nLength
+ 1) * sizeof(WCHAR
));
444 if (pPassword
== NULL
)
447 nCharsLen
= wcslen(szPasswordChars
);
449 for (i
= 0; i
< nLength
; i
++)
451 pPassword
[i
] = szPasswordChars
[rand() % nCharsLen
];
454 *lpPassword
= pPassword
;
461 BuildWorkstationsList(
462 _Out_ PWSTR
*pWorkstationsList
,
465 BOOL isLastSep
, isSep
;
473 /* Check for invalid characters in the raw string */
474 if (wcspbrk(pRaw
, L
"/[]=?\\+:.") != NULL
)
477 /* Count the number of workstations in the list and
478 * the required buffer size */
481 nRawLength
= wcslen(pRaw
);
482 for (i
= 0; i
< nRawLength
; i
++)
485 if (c
== L
',' || c
== L
';')
490 if ((isLastSep
== FALSE
) && (i
!= 0) && (i
!= nRawLength
- 1))
497 if (isLastSep
== TRUE
|| (isLastSep
== FALSE
&& i
== 0))
507 /* Leave, if there are no workstations in the list */
510 pWorkstationsList
= NULL
;
514 /* Fail if there are more than eight workstations in the list */
518 /* Allocate the buffer for the clean workstation list */
519 pList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, nLength
* sizeof(WCHAR
));
521 return ERROR_NOT_ENOUGH_MEMORY
;
523 /* Build the clean workstation list */
526 nRawLength
= wcslen(pRaw
);
527 for (i
= 0, j
= 0; i
< nRawLength
; i
++)
530 if (c
== L
',' || c
== L
';')
535 if ((isLastSep
== FALSE
) && (i
!= 0) && (i
!= nRawLength
- 1))
546 if (isLastSep
== TRUE
|| (isLastSep
== FALSE
&& i
== 0))
554 *pWorkstationsList
= pList
;
569 while (iswdigit(**s
))
571 *pwValue
= *pwValue
* 10 + **s
- L
'0';
584 if (**s
== L
'/' || **s
== L
'.')
600 SYSTEMTIME SystemTime
= {0};
601 FILETIME LocalFileTime
, FileTime
;
609 GetLocaleInfoW(LOCALE_USER_DEFAULT
,
618 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
620 if (!ReadSeparator(&p
))
622 if (!ReadNumber(&p
, &SystemTime
.wDay
))
624 if (!ReadSeparator(&p
))
626 if (!ReadNumber(&p
, &SystemTime
.wYear
))
631 if (!ReadNumber(&p
, &SystemTime
.wDay
))
633 if (!ReadSeparator(&p
))
635 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
637 if (!ReadSeparator(&p
))
639 if (!ReadNumber(&p
, &SystemTime
.wYear
))
644 if (!ReadNumber(&p
, &SystemTime
.wYear
))
646 if (!ReadSeparator(&p
))
648 if (!ReadNumber(&p
, &SystemTime
.wMonth
))
650 if (!ReadSeparator(&p
))
652 if (!ReadNumber(&p
, &SystemTime
.wDay
))
657 /* if only entered two digits: */
658 /* assume 2000's if value less than 80 */
659 /* assume 1900's if value greater or equal 80 */
660 if (SystemTime
.wYear
<= 99)
662 if (SystemTime
.wYear
>= 80)
663 SystemTime
.wYear
+= 1900;
665 SystemTime
.wYear
+= 2000;
668 if (!SystemTimeToFileTime(&SystemTime
, &LocalFileTime
))
671 if (!LocalFileTimeToFileTime(&LocalFileTime
, &FileTime
))
674 Time
.u
.LowPart
= FileTime
.dwLowDateTime
;
675 Time
.u
.HighPart
= FileTime
.dwHighDateTime
;
677 if (!RtlTimeToSecondsSince1970(&Time
, pSeconds
))
692 BOOL bDelete
= FALSE
;
694 BOOL bDomain
= FALSE
;
696 BOOL bRandomPassword
= FALSE
;
697 LPWSTR lpUserName
= NULL
;
698 LPWSTR lpPassword
= NULL
;
699 PUSER_INFO_4 pUserInfo
= NULL
;
700 USER_INFO_4 UserInfo
;
701 LPWSTR pWorkstations
= NULL
;
705 BOOL bPasswordAllocated
= FALSE
;
706 NET_API_STATUS Status
;
709 if ((i
< argc
) && (argv
[i
][0] != L
'/'))
711 lpUserName
= argv
[i
];
712 // ConPrintf(StdOut, L"User: %s\n", lpUserName);
716 if ((i
< argc
) && (argv
[i
][0] != L
'/'))
718 lpPassword
= argv
[i
];
719 // ConPrintf(StdOut, L"Password: %s\n", lpPassword);
723 for (j
= i
; j
< argc
; j
++)
725 if (_wcsicmp(argv
[j
], L
"/help") == 0)
727 PrintNetMessage(MSG_USER_HELP
);
730 else if (_wcsicmp(argv
[j
], L
"/add") == 0)
734 else if (_wcsicmp(argv
[j
], L
"/delete") == 0)
738 else if (_wcsicmp(argv
[j
], L
"/domain") == 0)
740 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/DOMAIN");
745 else if (_wcsicmp(argv
[j
], L
"/random") == 0)
747 bRandomPassword
= TRUE
;
748 GenerateRandomPassword(&lpPassword
,
749 &bPasswordAllocated
);
753 if (lpUserName
== NULL
&& lpPassword
== NULL
)
755 Status
= EnumerateUsers();
756 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
759 else if (lpUserName
!= NULL
&& lpPassword
== NULL
)
761 Status
= DisplayUser(lpUserName
);
762 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
772 /* Interactive password input */
773 if (lpPassword
!= NULL
&& wcscmp(lpPassword
, L
"*") == 0)
775 ReadPassword(&lpPassword
,
776 &bPasswordAllocated
);
779 if (!bAdd
&& !bDelete
)
781 /* Modify the user */
782 Status
= NetUserGetInfo(NULL
,
785 (LPBYTE
*)&pUserInfo
);
786 if (Status
!= NERR_Success
)
788 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
793 else if (bAdd
&& !bDelete
)
796 ZeroMemory(&UserInfo
, sizeof(USER_INFO_4
));
798 UserInfo
.usri4_name
= lpUserName
;
799 UserInfo
.usri4_password
= lpPassword
;
800 UserInfo
.usri4_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
;
801 UserInfo
.usri4_acct_expires
= TIMEQ_FOREVER
;
802 UserInfo
.usri4_primary_group_id
= DOMAIN_GROUP_RID_USERS
;
804 pUserInfo
= &UserInfo
;
807 for (j
= i
; j
< argc
; j
++)
809 if (_wcsnicmp(argv
[j
], L
"/active:", 8) == 0)
812 if (_wcsicmp(p
, L
"yes") == 0)
814 pUserInfo
->usri4_flags
&= ~UF_ACCOUNTDISABLE
;
816 else if (_wcsicmp(p
, L
"no") == 0)
818 pUserInfo
->usri4_flags
|= UF_ACCOUNTDISABLE
;
822 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/ACTIVE");
827 else if (_wcsnicmp(argv
[j
], L
"/comment:", 9) == 0)
829 pUserInfo
->usri4_comment
= &argv
[j
][9];
831 else if (_wcsnicmp(argv
[j
], L
"/countrycode:", 13) == 0)
834 value
= wcstoul(p
, &endptr
, 10);
837 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/COUNTRYCODE");
842 /* Verify the country code */
843 if (GetCountryFromCountryCode(value
, 0, NULL
))
844 pUserInfo
->usri4_country_code
= value
;
846 else if (_wcsnicmp(argv
[j
], L
"/expires:", 9) == 0)
849 if (_wcsicmp(p
, L
"never") == 0)
851 pUserInfo
->usri4_acct_expires
= TIMEQ_FOREVER
;
853 else if (!ParseDate(p
, &pUserInfo
->usri4_acct_expires
))
855 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/EXPIRES");
860 else if (_wcsnicmp(argv
[j
], L
"/fullname:", 10) == 0)
862 pUserInfo
->usri4_full_name
= &argv
[j
][10];
864 else if (_wcsnicmp(argv
[j
], L
"/homedir:", 9) == 0)
866 pUserInfo
->usri4_home_dir
= &argv
[j
][9];
868 else if (_wcsnicmp(argv
[j
], L
"/passwordchg:", 13) == 0)
871 if (_wcsicmp(p
, L
"yes") == 0)
873 pUserInfo
->usri4_flags
&= ~UF_PASSWD_CANT_CHANGE
;
875 else if (_wcsicmp(p
, L
"no") == 0)
877 pUserInfo
->usri4_flags
|= UF_PASSWD_CANT_CHANGE
;
881 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/PASSWORDCHG");
886 else if (_wcsnicmp(argv
[j
], L
"/passwordreq:", 13) == 0)
889 if (_wcsicmp(p
, L
"yes") == 0)
891 pUserInfo
->usri4_flags
&= ~UF_PASSWD_NOTREQD
;
893 else if (_wcsicmp(p
, L
"no") == 0)
895 pUserInfo
->usri4_flags
|= UF_PASSWD_NOTREQD
;
899 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/PASSWORDREQ");
904 else if (_wcsnicmp(argv
[j
], L
"/profilepath:", 13) == 0)
906 pUserInfo
->usri4_profile
= &argv
[j
][13];
908 else if (_wcsnicmp(argv
[j
], L
"/scriptpath:", 12) == 0)
910 pUserInfo
->usri4_script_path
= &argv
[j
][12];
912 else if (_wcsnicmp(argv
[j
], L
"/times:", 7) == 0)
915 ConResPrintf(StdErr
, IDS_ERROR_OPTION_NOT_SUPPORTED
, L
"/TIMES");
917 else if (_wcsnicmp(argv
[j
], L
"/usercomment:", 13) == 0)
919 pUserInfo
->usri4_usr_comment
= &argv
[j
][13];
921 else if (_wcsnicmp(argv
[j
], L
"/workstations:", 14) == 0)
924 if (wcscmp(p
, L
"*") == 0 || wcscmp(p
, L
"") == 0)
926 pUserInfo
->usri4_workstations
= NULL
;
930 Status
= BuildWorkstationsList(&pWorkstations
, p
);
931 if (Status
== NERR_Success
)
933 pUserInfo
->usri4_workstations
= pWorkstations
;
937 ConPrintf(StdOut
, L
"Status %lu\n\n", Status
);
945 if (!bAdd
&& !bDelete
)
947 /* Modify the user */
948 Status
= NetUserSetInfo(NULL
,
953 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
955 else if (bAdd
&& !bDelete
)
958 Status
= NetUserAdd(NULL
,
962 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
964 else if (!bAdd
&& bDelete
)
966 /* Delete the user */
967 Status
= NetUserDel(NULL
,
969 ConPrintf(StdOut
, L
"Status: %lu\n", Status
);
972 if (Status
== NERR_Success
&&
973 lpPassword
!= NULL
&&
974 bRandomPassword
== TRUE
)
976 ConPrintf(StdOut
, L
"The password for %s is: %s\n", lpUserName
, lpPassword
);
980 if (pWorkstations
!= NULL
)
981 HeapFree(GetProcessHeap(), 0, pWorkstations
);
983 if ((bPasswordAllocated
== TRUE
) && (lpPassword
!= NULL
))
984 HeapFree(GetProcessHeap(), 0, lpPassword
);
986 if (!bAdd
&& !bDelete
&& pUserInfo
!= NULL
)
987 NetApiBufferFree(pUserInfo
);
991 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
992 PrintNetMessage(MSG_USER_SYNTAX
);