ReactOS  0.4.13-dev-66-gc714b7f
cmdUser.c File Reference
#include "net.h"
Include dependency graph for cmdUser.c:

Go to the source code of this file.

Classes

struct  _COUNTY_TABLE
 

Typedefs

typedef struct _COUNTY_TABLE COUNTRY_TABLE
 
typedef struct _COUNTY_TABLEPCOUNTRY_TABLE
 

Functions

static int CompareInfo (const void *a, const void *b)
 
static NET_API_STATUS EnumerateUsers (VOID)
 
static VOID PrintDateTime (DWORD dwSeconds)
 
static DWORD GetTimeInSeconds (VOID)
 
static BOOL GetCountryFromCountryCode (_In_ DWORD dwCountryCode, _In_ DWORD dwCountryLength, _Out_ PWSTR szCountryBuffer)
 
static NET_API_STATUS DisplayUser (LPWSTR lpUserName)
 
static VOID ReadPassword (LPWSTR *lpPassword, LPBOOL lpAllocated)
 
static VOID GenerateRandomPassword (LPWSTR *lpPassword, LPBOOL lpAllocated)
 
static NET_API_STATUS BuildWorkstationsList (_Out_ PWSTR *pWorkstationsList, _In_ PWSTR pRaw)
 
static BOOL ReadNumber (PWSTR *s, PWORD pwValue)
 
static BOOL ReadSeparator (PWSTR *s)
 
static BOOL ParseDate (PWSTR s, PULONG pSeconds)
 
INT cmdUser (INT argc, WCHAR **argv)
 

Variables

static WCHAR szPasswordChars [] = L"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%_-+:"
 
static COUNTRY_TABLE CountryTable []
 

Typedef Documentation

◆ COUNTRY_TABLE

◆ PCOUNTRY_TABLE

Function Documentation

◆ BuildWorkstationsList()

static NET_API_STATUS BuildWorkstationsList ( _Out_ PWSTR pWorkstationsList,
_In_ PWSTR  pRaw 
)
static

Definition at line 460 of file cmdUser.c.

463 {
464  BOOL isLastSep, isSep;
465  INT i, j;
466  WCHAR c;
467  INT nLength = 0;
468  INT nArgs = 0;
469  INT nRawLength;
470  PWSTR pList;
471 
472  /* Check for invalid characters in the raw string */
473  if (wcspbrk(pRaw, L"/[]=?\\+:.") != NULL)
474  return 3952;
475 
476  /* Count the number of workstations in the list and
477  * the required buffer size */
478  isLastSep = FALSE;
479  isSep = FALSE;
480  nRawLength = wcslen(pRaw);
481  for (i = 0; i < nRawLength; i++)
482  {
483  c = pRaw[i];
484  if (c == L',' || c == L';')
485  isSep = TRUE;
486 
487  if (isSep == TRUE)
488  {
489  if ((isLastSep == FALSE) && (i != 0) && (i != nRawLength - 1))
490  nLength++;
491  }
492  else
493  {
494  nLength++;
495 
496  if (isLastSep == TRUE || (isLastSep == FALSE && i == 0))
497  nArgs++;
498  }
499 
500  isLastSep = isSep;
501  isSep = FALSE;
502  }
503 
504  nLength++;
505 
506  /* Leave, if there are no workstations in the list */
507  if (nArgs == 0)
508  {
509  pWorkstationsList = NULL;
510  return NERR_Success;
511  }
512 
513  /* Fail if there are more than eight workstations in the list */
514  if (nArgs > 8)
515  return 3951;
516 
517  /* Allocate the buffer for the clean workstation list */
518  pList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR));
519  if (pList == NULL)
521 
522  /* Build the clean workstation list */
523  isLastSep = FALSE;
524  isSep = FALSE;
525  nRawLength = wcslen(pRaw);
526  for (i = 0, j = 0; i < nRawLength; i++)
527  {
528  c = pRaw[i];
529  if (c == L',' || c == L';')
530  isSep = TRUE;
531 
532  if (isSep == TRUE)
533  {
534  if ((isLastSep == FALSE) && (i != 0) && (i != nRawLength - 1))
535  {
536  pList[j] = L',';
537  j++;
538  }
539  }
540  else
541  {
542  pList[j] = c;
543  j++;
544 
545  if (isLastSep == TRUE || (isLastSep == FALSE && i == 0))
546  nArgs++;
547  }
548 
549  isLastSep = isSep;
550  isSep = FALSE;
551  }
552 
553  *pWorkstationsList = pList;
554 
555  return NERR_Success;
556 }
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:54
_In_ DWORD nLength
Definition: wincon.h:461
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
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
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define c
Definition: ke_i.h:80
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by cmdUser().

◆ cmdUser()

INT cmdUser ( INT  argc,
WCHAR **  argv 
)

Definition at line 684 of file cmdUser.c.

687 {
688  INT i, j;
689  INT result = 0;
690  BOOL bAdd = FALSE;
691  BOOL bDelete = FALSE;
692 #if 0
693  BOOL bDomain = FALSE;
694 #endif
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;
701  LPWSTR p;
702  LPWSTR endptr;
703  DWORD value;
704  BOOL bPasswordAllocated = FALSE;
706 
707  i = 2;
708  if ((i < argc) && (argv[i][0] != L'/'))
709  {
710  lpUserName = argv[i];
711 // ConPrintf(StdOut, L"User: %s\n", lpUserName);
712  i++;
713  }
714 
715  if ((i < argc) && (argv[i][0] != L'/'))
716  {
717  lpPassword = argv[i];
718 // ConPrintf(StdOut, L"Password: %s\n", lpPassword);
719  i++;
720  }
721 
722  for (j = i; j < argc; j++)
723  {
724  if (_wcsicmp(argv[j], L"/help") == 0)
725  {
726  PrintNetMessage(MSG_USER_HELP);
727  return 0;
728  }
729  else if (_wcsicmp(argv[j], L"/add") == 0)
730  {
731  bAdd = TRUE;
732  }
733  else if (_wcsicmp(argv[j], L"/delete") == 0)
734  {
735  bDelete = TRUE;
736  }
737  else if (_wcsicmp(argv[j], L"/domain") == 0)
738  {
739  ConPuts(StdErr, L"The /DOMAIN option is not supported yet.\n");
740 #if 0
741  bDomain = TRUE;
742 #endif
743  }
744  else if (_wcsicmp(argv[j], L"/random") == 0)
745  {
746  bRandomPassword = TRUE;
747  GenerateRandomPassword(&lpPassword,
748  &bPasswordAllocated);
749  }
750  }
751 
752  if (lpUserName == NULL && lpPassword == NULL)
753  {
755  ConPrintf(StdOut, L"Status: %lu\n", Status);
756  return 0;
757  }
758  else if (lpUserName != NULL && lpPassword == NULL)
759  {
760  Status = DisplayUser(lpUserName);
761  ConPrintf(StdOut, L"Status: %lu\n", Status);
762  return 0;
763  }
764 
765  if (bAdd && bDelete)
766  {
767  result = 1;
768  goto done;
769  }
770 
771  /* Interactive password input */
772  if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
773  {
774  ReadPassword(&lpPassword,
775  &bPasswordAllocated);
776  }
777 
778  if (!bAdd && !bDelete)
779  {
780  /* Modify the user */
782  lpUserName,
783  4,
784  (LPBYTE*)&pUserInfo);
785  if (Status != NERR_Success)
786  {
787  ConPrintf(StdOut, L"Status: %lu\n", Status);
788  result = 1;
789  goto done;
790  }
791  }
792  else if (bAdd && !bDelete)
793  {
794  /* Add the user */
795  ZeroMemory(&UserInfo, sizeof(USER_INFO_4));
796 
797  UserInfo.usri4_name = lpUserName;
798  UserInfo.usri4_password = lpPassword;
802 
803  pUserInfo = &UserInfo;
804  }
805 
806  for (j = i; j < argc; j++)
807  {
808  if (_wcsnicmp(argv[j], L"/active:", 8) == 0)
809  {
810  p = &argv[i][8];
811  if (_wcsicmp(p, L"yes") == 0)
812  {
813  pUserInfo->usri4_flags &= ~UF_ACCOUNTDISABLE;
814  }
815  else if (_wcsicmp(p, L"no") == 0)
816  {
817  pUserInfo->usri4_flags |= UF_ACCOUNTDISABLE;
818  }
819  else
820  {
821  PrintMessageStringV(3952, L"/ACTIVE");
822  result = 1;
823  goto done;
824  }
825  }
826  else if (_wcsnicmp(argv[j], L"/comment:", 9) == 0)
827  {
828  pUserInfo->usri4_comment = &argv[j][9];
829  }
830  else if (_wcsnicmp(argv[j], L"/countrycode:", 13) == 0)
831  {
832  p = &argv[i][13];
833  value = wcstoul(p, &endptr, 10);
834  if (*endptr != 0)
835  {
836  PrintMessageStringV(3952, L"/COUNTRYCODE");
837  result = 1;
838  goto done;
839  }
840 
841  /* Verify the country code */
843  pUserInfo->usri4_country_code = value;
844  }
845  else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
846  {
847  p = &argv[i][9];
848  if (_wcsicmp(p, L"never") == 0)
849  {
850  pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
851  }
852  else if (!ParseDate(p, &pUserInfo->usri4_acct_expires))
853  {
854  PrintMessageStringV(3952, L"/EXPIRES");
855  result = 1;
856  goto done;
857  }
858  }
859  else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
860  {
861  pUserInfo->usri4_full_name = &argv[j][10];
862  }
863  else if (_wcsnicmp(argv[j], L"/homedir:", 9) == 0)
864  {
865  pUserInfo->usri4_home_dir = &argv[j][9];
866  }
867  else if (_wcsnicmp(argv[j], L"/passwordchg:", 13) == 0)
868  {
869  p = &argv[i][13];
870  if (_wcsicmp(p, L"yes") == 0)
871  {
872  pUserInfo->usri4_flags &= ~UF_PASSWD_CANT_CHANGE;
873  }
874  else if (_wcsicmp(p, L"no") == 0)
875  {
876  pUserInfo->usri4_flags |= UF_PASSWD_CANT_CHANGE;
877  }
878  else
879  {
880  PrintMessageStringV(3952, L"/PASSWORDCHG");
881  result = 1;
882  goto done;
883  }
884  }
885  else if (_wcsnicmp(argv[j], L"/passwordreq:", 13) == 0)
886  {
887  p = &argv[i][13];
888  if (_wcsicmp(p, L"yes") == 0)
889  {
890  pUserInfo->usri4_flags &= ~UF_PASSWD_NOTREQD;
891  }
892  else if (_wcsicmp(p, L"no") == 0)
893  {
894  pUserInfo->usri4_flags |= UF_PASSWD_NOTREQD;
895  }
896  else
897  {
898  PrintMessageStringV(3952, L"/PASSWORDREQ");
899  result = 1;
900  goto done;
901  }
902  }
903  else if (_wcsnicmp(argv[j], L"/profilepath:", 13) == 0)
904  {
905  pUserInfo->usri4_profile = &argv[j][13];
906  }
907  else if (_wcsnicmp(argv[j], L"/scriptpath:", 12) == 0)
908  {
909  pUserInfo->usri4_script_path = &argv[j][12];
910  }
911  else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
912  {
913  /* FIXME */
914  ConPuts(StdErr, L"The /TIMES option is not supported yet.\n");
915  }
916  else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
917  {
918  pUserInfo->usri4_usr_comment = &argv[j][13];
919  }
920  else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
921  {
922  p = &argv[i][14];
923  if (wcscmp(p, L"*") == 0 || wcscmp(p, L"") == 0)
924  {
925  pUserInfo->usri4_workstations = NULL;
926  }
927  else
928  {
929  Status = BuildWorkstationsList(&pWorkstations, p);
930  if (Status == NERR_Success)
931  {
932  pUserInfo->usri4_workstations = pWorkstations;
933  }
934  else
935  {
936  ConPrintf(StdOut, L"Status %lu\n\n", Status);
937  result = 1;
938  goto done;
939  }
940  }
941  }
942  }
943 
944  if (!bAdd && !bDelete)
945  {
946  /* Modify the user */
948  lpUserName,
949  4,
950  (LPBYTE)pUserInfo,
951  NULL);
952  ConPrintf(StdOut, L"Status: %lu\n", Status);
953  }
954  else if (bAdd && !bDelete)
955  {
956  /* Add the user */
958  4,
959  (LPBYTE)pUserInfo,
960  NULL);
961  ConPrintf(StdOut, L"Status: %lu\n", Status);
962  }
963  else if (!bAdd && bDelete)
964  {
965  /* Delete the user */
967  lpUserName);
968  ConPrintf(StdOut, L"Status: %lu\n", Status);
969  }
970 
971  if (Status == NERR_Success &&
972  lpPassword != NULL &&
973  bRandomPassword == TRUE)
974  {
975  PrintMessageStringV(3968, lpUserName, lpPassword);
976  }
977 
978 done:
979  if (pWorkstations != NULL)
980  HeapFree(GetProcessHeap(), 0, pWorkstations);
981 
982  if ((bPasswordAllocated == TRUE) && (lpPassword != NULL))
983  HeapFree(GetProcessHeap(), 0, lpPassword);
984 
985  if (!bAdd && !bDelete && pUserInfo != NULL)
986  NetApiBufferFree(pUserInfo);
987 
988  if (result != 0)
989  {
990  PrintMessageString(4381);
991  ConPuts(StdOut, L"\n");
992  PrintNetMessage(MSG_USER_SYNTAX);
993  }
994 
995  return result;
996 }
static NET_API_STATUS DisplayUser(LPWSTR lpUserName)
Definition: cmdUser.c:201
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:82
_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)
LPWSTR usri4_home_dir
Definition: lmaccess.h:274
#define ZeroMemory
Definition: winbase.h:1635
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:228
DWORD usri4_flags
Definition: lmaccess.h:276
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
DWORD usri4_country_code
Definition: lmaccess.h:292
#define UF_PASSWD_CANT_CHANGE
Definition: lmaccess.h:28
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
static NET_API_STATUS EnumerateUsers(VOID)
Definition: cmdUser.c:60
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR usri4_workstations
Definition: lmaccess.h:282
LPWSTR usri4_full_name
Definition: lmaccess.h:279
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
Definition: user.c:2290
DWORD usri4_primary_group_id
Definition: lmaccess.h:295
LPWSTR usri4_password
Definition: lmaccess.h:271
smooth NULL
Definition: ftsmooth.c:416
#define UF_PASSWD_NOTREQD
Definition: lmaccess.h:27
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3164
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
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define GetProcessHeap()
Definition: compat.h:395
DWORD usri4_acct_expires
Definition: lmaccess.h:285
static VOID ReadPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:385
LPWSTR usri4_profile
Definition: lmaccess.h:296
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL ParseDate(PWSTR s, PULONG pSeconds)
Definition: cmdUser.c:595
#define StdErr
Definition: stream.h:77
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
Definition: user.c:2560
static const WCHAR L[]
Definition: oid.c:1250
LPWSTR usri4_comment
Definition: lmaccess.h:275
GLsizei const GLfloat * value
Definition: glext.h:6069
static NET_API_STATUS BuildWorkstationsList(_Out_ PWSTR *pWorkstationsList, _In_ PWSTR pRaw)
Definition: cmdUser.c:460
Status
Definition: gdiplustypes.h:24
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NET_API_STATUS WINAPI NetUserSetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: user.c:3992
static VOID GenerateRandomPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:431
LPWSTR usri4_usr_comment
Definition: lmaccess.h:280
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:109
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:612
#define UF_NORMAL_ACCOUNT
Definition: lmaccess.h:30
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define StdOut
Definition: stream.h:76
LPWSTR usri4_name
Definition: lmaccess.h:270
LPWSTR usri4_script_path
Definition: lmaccess.h:277
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static BOOL GetCountryFromCountryCode(_In_ DWORD dwCountryCode, _In_ DWORD dwCountryLength, _Out_ PWSTR szCountryBuffer)
Definition: cmdUser.c:169
#define UF_SCRIPT
Definition: lmaccess.h:23

◆ CompareInfo()

static int CompareInfo ( const void a,
const void b 
)
static

Definition at line 51 of file cmdUser.c.

52 {
53  return _wcsicmp(((PUSER_INFO_0)a)->usri0_name,
54  ((PUSER_INFO_0)b)->usri0_name);
55 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by EnumerateUsers().

◆ DisplayUser()

static NET_API_STATUS DisplayUser ( LPWSTR  lpUserName)
static

Definition at line 201 of file cmdUser.c.

202 {
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;
209  DWORD dwLastSet;
210  DWORD i;
211  WCHAR szCountry[40];
212  INT nPaddedLength = 36;
214 
215  /* Modify the user */
217  lpUserName,
218  4,
219  (LPBYTE*)&pUserInfo);
220  if (Status != NERR_Success)
221  return Status;
222 
224  0,
225  (LPBYTE*)&pUserModals);
226  if (Status != NERR_Success)
227  goto done;
228 
230  lpUserName,
231  0,
232  0,
233  (LPBYTE*)&pLocalGroupInfo,
235  &dwLocalGroupRead,
236  &dwLocalGroupTotal);
237  if (Status != NERR_Success)
238  goto done;
239 
241  lpUserName,
242  0,
243  (LPBYTE*)&pGroupInfo,
245  &dwGroupRead,
246  &dwGroupTotal);
247  if (Status != NERR_Success)
248  goto done;
249 
250  PrintPaddedMessageString(4411, nPaddedLength);
251  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_name);
252 
253  PrintPaddedMessageString(4412, nPaddedLength);
254  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_full_name);
255 
256  PrintPaddedMessageString(4413, nPaddedLength);
257  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_comment);
258 
259  PrintPaddedMessageString(4414, nPaddedLength);
260  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_usr_comment);
261 
262  PrintPaddedMessageString(4416, nPaddedLength);
264  ARRAYSIZE(szCountry), szCountry);
265  ConPrintf(StdOut, L"%03ld (%s)\n", pUserInfo->usri4_country_code, szCountry);
266 
267  PrintPaddedMessageString(4419, nPaddedLength);
268  if (pUserInfo->usri4_flags & UF_ACCOUNTDISABLE)
269  PrintMessageString(4301);
270  else if (pUserInfo->usri4_flags & UF_LOCKOUT)
271  PrintMessageString(4440);
272  else
273  PrintMessageString(4300);
274  ConPuts(StdOut, L"\n");
275 
276  PrintPaddedMessageString(4420, nPaddedLength);
277  if (pUserInfo->usri4_acct_expires == TIMEQ_FOREVER)
278  PrintMessageString(4305);
279  else
280  PrintDateTime(pUserInfo->usri4_acct_expires);
281  ConPuts(StdOut, L"\n\n");
282 
283  PrintPaddedMessageString(4421, nPaddedLength);
284  dwLastSet = GetTimeInSeconds() - pUserInfo->usri4_password_age;
285  PrintDateTime(dwLastSet);
286  ConPuts(StdOut, L"\n");
287 
288  PrintPaddedMessageString(4422, nPaddedLength);
289  if ((pUserInfo->usri4_flags & UF_DONT_EXPIRE_PASSWD) || pUserModals->usrmod0_max_passwd_age == TIMEQ_FOREVER)
290  PrintMessageString(4305);
291  else
292  PrintDateTime(dwLastSet + pUserModals->usrmod0_max_passwd_age);
293  ConPuts(StdOut, L"\n");
294 
295  PrintPaddedMessageString(4423, nPaddedLength);
296  PrintDateTime(dwLastSet + pUserModals->usrmod0_min_passwd_age);
297  ConPuts(StdOut, L"\n");
298 
299  PrintPaddedMessageString(4437, nPaddedLength);
300  PrintMessageString((pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? 4301 : 4300);
301  ConPuts(StdOut, L"\n");
302 
303  PrintPaddedMessageString(4438, nPaddedLength);
304  PrintMessageString((pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? 4301 : 4300);
305  ConPuts(StdOut, L"\n\n");
306 
307  PrintPaddedMessageString(4424, nPaddedLength);
308  if (pUserInfo->usri4_workstations == NULL || wcslen(pUserInfo->usri4_workstations) == 0)
309  PrintMessageString(4302);
310  else
311  ConPrintf(StdOut, L"%s", pUserInfo->usri4_workstations);
312  ConPuts(StdOut, L"\n");
313 
314  PrintPaddedMessageString(4429, nPaddedLength);
315  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_script_path);
316 
317  PrintPaddedMessageString(4439, nPaddedLength);
318  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_profile);
319 
320  PrintPaddedMessageString(4436, nPaddedLength);
321  ConPrintf(StdOut, L"%s\n", pUserInfo->usri4_home_dir);
322 
323  PrintPaddedMessageString(4430, nPaddedLength);
324  if (pUserInfo->usri4_last_logon == 0)
325  PrintMessageString(4305);
326  else
327  PrintDateTime(pUserInfo->usri4_last_logon);
328  ConPuts(StdOut, L"\n\n");
329 
330  PrintPaddedMessageString(4432, nPaddedLength);
331  if (pUserInfo->usri4_logon_hours == NULL)
332  PrintMessageString(4302);
333  ConPuts(StdOut, L"\n\n");
334 
335  ConPuts(StdOut, L"\n");
336  PrintPaddedMessageString(4427, nPaddedLength);
337  if (dwLocalGroupTotal != 0 && pLocalGroupInfo != NULL)
338  {
339  for (i = 0; i < dwLocalGroupTotal; i++)
340  {
341  if (i != 0)
342  PrintPadding(L' ', nPaddedLength);
343  ConPrintf(StdOut, L"*%s\n", pLocalGroupInfo[i].lgrui0_name);
344  }
345  }
346  else
347  {
348  ConPuts(StdOut, L"\n");
349  }
350 
351  PrintPaddedMessageString(4431, nPaddedLength);
352  if (dwGroupTotal != 0 && pGroupInfo != NULL)
353  {
354  for (i = 0; i < dwGroupTotal; i++)
355  {
356  if (i != 0)
357  PrintPadding(L' ', nPaddedLength);
358  ConPrintf(StdOut, L"*%s\n", pGroupInfo[i].grui0_name);
359  }
360  }
361  else
362  {
363  ConPuts(StdOut, L"\n");
364  }
365 
366 done:
367  if (pGroupInfo != NULL)
368  NetApiBufferFree(pGroupInfo);
369 
370  if (pLocalGroupInfo != NULL)
371  NetApiBufferFree(pLocalGroupInfo);
372 
373  if (pUserModals != NULL)
374  NetApiBufferFree(pUserModals);
375 
376  if (pUserInfo != NULL)
377  NetApiBufferFree(pUserInfo);
378 
379  return NERR_Success;
380 }
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
LPWSTR usri4_home_dir
Definition: lmaccess.h:274
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD usri4_flags
Definition: lmaccess.h:276
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
DWORD usri4_country_code
Definition: lmaccess.h:292
#define UF_PASSWD_CANT_CHANGE
Definition: lmaccess.h:28
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
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD usrmod0_max_passwd_age
Definition: lmaccess.h:434
NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR servername, DWORD level, LPBYTE *bufptr)
Definition: user.c:3676
DWORD usri4_last_logon
Definition: lmaccess.h:283
LPWSTR usri4_workstations
Definition: lmaccess.h:282
LPWSTR usri4_full_name
Definition: lmaccess.h:279
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
#define UF_PASSWD_NOTREQD
Definition: lmaccess.h:27
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3164
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NET_API_STATUS WINAPI NetUserGetLocalGroups(LPCWSTR servername, LPCWSTR username, DWORD level, DWORD flags, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries)
Definition: user.c:3341
DWORD usri4_acct_expires
Definition: lmaccess.h:285
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR usri4_profile
Definition: lmaccess.h:296
unsigned long DWORD
Definition: ntddk_ex.h:95
NET_API_STATUS WINAPI NetUserGetGroups(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr, DWORD prefixmaxlen, LPDWORD entriesread, LPDWORD totalentries)
Definition: user.c:2999
DWORD usri4_password_age
Definition: lmaccess.h:272
DWORD usrmod0_min_passwd_age
Definition: lmaccess.h:435
static const WCHAR L[]
Definition: oid.c:1250
LPWSTR usri4_comment
Definition: lmaccess.h:275
#define UF_DONT_EXPIRE_PASSWD
Definition: lmaccess.h:37
Status
Definition: gdiplustypes.h:24
LPWSTR usri4_usr_comment
Definition: lmaccess.h:280
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPaddedMessageString(DWORD dwMessage, INT nPaddedLength)
Definition: main.c:132
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:109
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
PBYTE usri4_logon_hours
Definition: lmaccess.h:288
VOID PrintPadding(WCHAR chr, INT nPaddedLength)
Definition: main.c:66
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define UF_LOCKOUT
Definition: lmaccess.h:26
#define StdOut
Definition: stream.h:76
LPWSTR usri4_name
Definition: lmaccess.h:270
LPWSTR usri4_script_path
Definition: lmaccess.h:277
static VOID PrintDateTime(DWORD dwSeconds)
Definition: cmdUser.c:118
static DWORD GetTimeInSeconds(VOID)
Definition: cmdUser.c:152
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static BOOL GetCountryFromCountryCode(_In_ DWORD dwCountryCode, _In_ DWORD dwCountryLength, _Out_ PWSTR szCountryBuffer)
Definition: cmdUser.c:169

Referenced by cmdUser().

◆ EnumerateUsers()

static NET_API_STATUS EnumerateUsers ( VOID  )
static

Definition at line 60 of file cmdUser.c.

61 {
63  PSERVER_INFO_100 pServer = NULL;
64  DWORD dwRead = 0, dwTotal = 0;
65  DWORD i;
66  DWORD ResumeHandle = 0;
68 
70  100,
71  (LPBYTE*)&pServer);
72  if (Status != NERR_Success)
73  return Status;
74 
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");
80 
81  NetApiBufferFree(pServer);
82 
83  do
84  {
86  0,
87  0,
88  (LPBYTE*)&pBuffer,
90  &dwRead,
91  &dwTotal,
92  &ResumeHandle);
93  if ((Status != NERR_Success) && (Status != ERROR_MORE_DATA))
94  return Status;
95 
96  qsort(pBuffer,
97  dwRead,
98  sizeof(PUSER_INFO_0),
99  CompareInfo);
100 
101  for (i = 0; i < dwRead; i++)
102  {
103  if (pBuffer[i].usri0_name)
104  ConPrintf(StdOut, L"%s\n", pBuffer[i].usri0_name);
105  }
106 
108  pBuffer = NULL;
109  }
110  while (Status == ERROR_MORE_DATA);
111 
112  return NERR_Success;
113 }
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:82
static int CompareInfo(const void *a, const void *b)
Definition: cmdUser.c:51
#define NERR_Success
Definition: lmerr.h:5
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
unsigned char * LPBYTE
Definition: typedefs.h:52
LPWSTR sv100_name
Definition: lmserver.h:13
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
#define ERROR_MORE_DATA
Definition: dderror.h:13
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPadding(WCHAR chr, INT nPaddedLength)
Definition: main.c:66
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76
NET_API_STATUS WINAPI NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, LPDWORD resume_handle)
Definition: user.c:2757

Referenced by cmdUser().

◆ GenerateRandomPassword()

static VOID GenerateRandomPassword ( LPWSTR lpPassword,
LPBOOL  lpAllocated 
)
static

Definition at line 431 of file cmdUser.c.

434 {
435  LPWSTR pPassword = NULL;
436  INT nCharsLen, i, nLength = 8;
437 
438  srand(GetTickCount());
439 
440  pPassword = HeapAlloc(GetProcessHeap(),
442  (nLength + 1) * sizeof(WCHAR));
443  if (pPassword == NULL)
444  return;
445 
446  nCharsLen = wcslen(szPasswordChars);
447 
448  for (i = 0; i < nLength; i++)
449  {
450  pPassword[i] = szPasswordChars[rand() % nCharsLen];
451  }
452 
453  *lpPassword = pPassword;
454  *lpAllocated = TRUE;
455 }
#define TRUE
Definition: types.h:120
_In_ DWORD nLength
Definition: wincon.h:461
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
void __cdecl srand(_In_ unsigned int _Seed)
int32_t INT
Definition: typedefs.h:56
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_ int __cdecl rand(void)
Definition: rand.c:10
static WCHAR szPasswordChars[]
Definition: cmdUser.c:20
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by cmdUser().

◆ GetCountryFromCountryCode()

static BOOL GetCountryFromCountryCode ( _In_ DWORD  dwCountryCode,
_In_ DWORD  dwCountryLength,
_Out_ PWSTR  szCountryBuffer 
)
static

Definition at line 169 of file cmdUser.c.

173 {
174  DWORD i;
175 
176  for (i = 0; i < ARRAYSIZE(CountryTable); i++)
177  {
178  if (CountryTable[i].dwCountryCode == dwCountryCode)
179  {
180  if (szCountryBuffer != NULL && dwCountryLength > 0)
181  {
184  CountryTable[i].dwMessageId,
186  szCountryBuffer,
187  dwCountryLength,
188  NULL);
189  }
190 
191  return TRUE;
192  }
193  }
194 
195  return FALSE;
196 }
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
static COUNTRY_TABLE CountryTable[]
Definition: cmdUser.c:21
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
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
HMODULE hModuleNetMsg
Definition: main.c:49
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

Referenced by cmdUser(), and DisplayUser().

◆ GetTimeInSeconds()

static DWORD GetTimeInSeconds ( VOID  )
static

Definition at line 152 of file cmdUser.c.

153 {
155  FILETIME FileTime;
156  DWORD dwSeconds;
157 
158  GetSystemTimeAsFileTime(&FileTime);
159  Time.u.LowPart = FileTime.dwLowDateTime;
160  Time.u.HighPart = FileTime.dwHighDateTime;
161  RtlTimeToSecondsSince1970(&Time, &dwSeconds);
162 
163  return dwSeconds;
164 }
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
DWORD dwHighDateTime
Definition: mapidefs.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _LARGE_INTEGER::@2192 u
static PLARGE_INTEGER Time
Definition: time.c:105
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by DisplayUser().

◆ ParseDate()

static BOOL ParseDate ( PWSTR  s,
PULONG  pSeconds 
)
static

Definition at line 595 of file cmdUser.c.

598 {
599  SYSTEMTIME SystemTime = {0};
600  FILETIME LocalFileTime, FileTime;
602  INT nDateFormat = 0;
603  PWSTR p = s;
604 
605  if (!*s)
606  return FALSE;
607 
609  LOCALE_IDATE,
610  (PWSTR)&nDateFormat,
611  sizeof(INT));
612 
613  switch (nDateFormat)
614  {
615  case 0: /* mmddyy */
616  default:
617  if (!ReadNumber(&p, &SystemTime.wMonth))
618  return FALSE;
619  if (!ReadSeparator(&p))
620  return FALSE;
621  if (!ReadNumber(&p, &SystemTime.wDay))
622  return FALSE;
623  if (!ReadSeparator(&p))
624  return FALSE;
625  if (!ReadNumber(&p, &SystemTime.wYear))
626  return FALSE;
627  break;
628 
629  case 1: /* ddmmyy */
630  if (!ReadNumber(&p, &SystemTime.wDay))
631  return FALSE;
632  if (!ReadSeparator(&p))
633  return FALSE;
634  if (!ReadNumber(&p, &SystemTime.wMonth))
635  return FALSE;
636  if (!ReadSeparator(&p))
637  return FALSE;
638  if (!ReadNumber(&p, &SystemTime.wYear))
639  return FALSE;
640  break;
641 
642  case 2: /* yymmdd */
643  if (!ReadNumber(&p, &SystemTime.wYear))
644  return FALSE;
645  if (!ReadSeparator(&p))
646  return FALSE;
647  if (!ReadNumber(&p, &SystemTime.wMonth))
648  return FALSE;
649  if (!ReadSeparator(&p))
650  return FALSE;
651  if (!ReadNumber(&p, &SystemTime.wDay))
652  return FALSE;
653  break;
654  }
655 
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)
660  {
661  if (SystemTime.wYear >= 80)
662  SystemTime.wYear += 1900;
663  else
664  SystemTime.wYear += 2000;
665  }
666 
667  if (!SystemTimeToFileTime(&SystemTime, &LocalFileTime))
668  return FALSE;
669 
670  if (!LocalFileTimeToFileTime(&LocalFileTime, &FileTime))
671  return FALSE;
672 
673  Time.u.LowPart = FileTime.dwLowDateTime;
674  Time.u.HighPart = FileTime.dwHighDateTime;
675 
676  if (!RtlTimeToSecondsSince1970(&Time, pSeconds))
677  return FALSE;
678 
679  return TRUE;
680 }
#define TRUE
Definition: types.h:120
WORD wMonth
Definition: winbase.h:871
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
uint16_t * PWSTR
Definition: typedefs.h:54
#define LOCALE_IDATE
Definition: winnls.h:63
#define LOCALE_USER_DEFAULT
int32_t INT
Definition: typedefs.h:56
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
BOOL WINAPI LocalFileTimeToFileTime(IN CONST FILETIME *lpLocalFileTime, OUT LPFILETIME lpFileTime)
Definition: time.c:243
DWORD dwHighDateTime
Definition: mapidefs.h:66
WORD wYear
Definition: winbase.h:870
static BOOL ReadNumber(PWSTR *s, PWORD pwValue)
Definition: cmdUser.c:561
GLdouble s
Definition: gl.h:2039
WORD wDay
Definition: winbase.h:873
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
struct _LARGE_INTEGER::@2192 u
INT nDateFormat
Definition: locale.c:20
static BOOL ReadSeparator(PWSTR *s)
Definition: cmdUser.c:580
GLfloat GLfloat p
Definition: glext.h:8902
static PLARGE_INTEGER Time
Definition: time.c:105
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by cmdUser().

◆ PrintDateTime()

static VOID PrintDateTime ( DWORD  dwSeconds)
static

Definition at line 118 of file cmdUser.c.

119 {
121  FILETIME FileTime;
122  SYSTEMTIME SystemTime;
123  WCHAR DateBuffer[80];
124  WCHAR TimeBuffer[80];
125 
126  RtlSecondsSince1970ToTime(dwSeconds, &Time);
127  FileTime.dwLowDateTime = Time.u.LowPart;
128  FileTime.dwHighDateTime = Time.u.HighPart;
129  FileTimeToLocalFileTime(&FileTime, &FileTime);
130  FileTimeToSystemTime(&FileTime, &SystemTime);
131 
134  &SystemTime,
135  NULL,
136  DateBuffer,
137  80);
138 
141  &SystemTime,
142  NULL,
143  TimeBuffer,
144  80);
145 
146  ConPrintf(StdOut, L"%s %s", DateBuffer, TimeBuffer);
147 }
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
DWORD dwHighDateTime
Definition: mapidefs.h:66
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
struct _LARGE_INTEGER::@2192 u
#define StdOut
Definition: stream.h:76
#define TIME_NOSECONDS
Definition: winnls.h:275
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079
static PLARGE_INTEGER Time
Definition: time.c:105
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by DisplayUser().

◆ ReadNumber()

static BOOL ReadNumber ( PWSTR s,
PWORD  pwValue 
)
static

Definition at line 561 of file cmdUser.c.

564 {
565  if (!iswdigit(**s))
566  return FALSE;
567 
568  while (iswdigit(**s))
569  {
570  *pwValue = *pwValue * 10 + **s - L'0';
571  (*s)++;
572  }
573 
574  return TRUE;
575 }
#define TRUE
Definition: types.h:120
#define iswdigit(_c)
Definition: ctype.h:667
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039

Referenced by ParseDate().

◆ ReadPassword()

static VOID ReadPassword ( LPWSTR lpPassword,
LPBOOL  lpAllocated 
)
static

Definition at line 385 of file cmdUser.c.

388 {
389  WCHAR szPassword1[PWLEN + 1];
390  WCHAR szPassword2[PWLEN + 1];
391  LPWSTR ptr;
392 
393  *lpAllocated = FALSE;
394 
395  while (TRUE)
396  {
397  PrintMessageString(4358);
398  ReadFromConsole(szPassword1, PWLEN + 1, FALSE);
399  ConPuts(StdOut, L"\n");
400 
401  PrintMessageString(4361);
402  ReadFromConsole(szPassword2, PWLEN + 1, FALSE);
403  ConPuts(StdOut, L"\n");
404 
405  if (wcslen(szPassword1) == wcslen(szPassword2) &&
406  wcscmp(szPassword1, szPassword2) == 0)
407  {
409  0,
410  (wcslen(szPassword1) + 1) * sizeof(WCHAR));
411  if (ptr != NULL)
412  {
413  wcscpy(ptr, szPassword1);
414  *lpPassword = ptr;
415  *lpAllocated = TRUE;
416  return;
417  }
418  }
419  else
420  {
421  ConPuts(StdOut, L"\n");
422  PrintMessageString(3728);
423  *lpPassword = NULL;
424  }
425  }
426 }
#define TRUE
Definition: types.h:120
#define PWLEN
Definition: lmcons.h:37
VOID ReadFromConsole(LPWSTR lpInput, DWORD dwLength, BOOL bEcho)
Definition: main.c:253
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:109
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by cmdUser().

◆ ReadSeparator()

static BOOL ReadSeparator ( PWSTR s)
static

Definition at line 580 of file cmdUser.c.

582 {
583  if (**s == L'/' || **s == L'.')
584  {
585  (*s)++;
586  return TRUE;
587  }
588 
589  return FALSE;
590 }
#define TRUE
Definition: types.h:120
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039

Referenced by ParseDate().

Variable Documentation

◆ CountryTable

COUNTRY_TABLE CountryTable[]
static
Initial value:
=
{ { 0, 5080},
{ 1, 5081},
{ 2, 5082},
{ 3, 5083},
{ 31, 5084},
{ 32, 5085},
{ 33, 5086},
{ 34, 5090},
{ 39, 5087},
{ 41, 5088},
{ 44, 5089},
{ 45, 5091},
{ 46, 5092},
{ 47, 5093},
{ 49, 5094},
{ 61, 5095},
{ 81, 5096},
{ 82, 5097},
{ 86, 5098},
{ 88, 5099},
{ 99, 5100},
{351, 5101},
{358, 5102},
{785, 5103},
{972, 5104} }

Definition at line 21 of file cmdUser.c.

Referenced by GetCountryFromCountryCode().

◆ szPasswordChars

WCHAR szPasswordChars[] = L"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%_-+:"
static

Definition at line 20 of file cmdUser.c.

Referenced by GenerateRandomPassword().