Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.2 KiB

  1. /*
  2. File: main.c, main.cpp
  3. Simple test shell.
  4. Paul Mayfield, 4/13/98
  5. */
  6. #ifndef UNICODE
  7. #define UNICODE
  8. #endif
  9. #ifndef _UNICODE
  10. #define _UNICODE
  11. #endif
  12. #include <windows.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <mprapi.h>
  16. #include <rtutils.h>
  17. #define DWERR_BREAK(dwErr) {if (dwErr != NO_ERROR) break;}
  18. DWORD
  19. DsrDomainSetAccess(
  20. IN PWCHAR pszDomain,
  21. IN DWORD dwAccessFlags);
  22. //
  23. // Initializes the trace mechanism
  24. //
  25. DWORD
  26. DsrTraceInit()
  27. {
  28. return NO_ERROR;
  29. }
  30. //
  31. // Cleans up the trace mechansim
  32. //
  33. DWORD
  34. DsrTraceCleanup()
  35. {
  36. return NO_ERROR;
  37. }
  38. //
  39. // Sends debug trace and returns the given error
  40. //
  41. DWORD
  42. DsrTraceEx (
  43. IN DWORD dwErr,
  44. IN LPSTR pszTrace,
  45. IN ...)
  46. {
  47. va_list arglist;
  48. char szTemp[1024];
  49. va_start(arglist, pszTrace);
  50. vsprintf(szTemp, pszTrace, arglist);
  51. va_end(arglist);
  52. printf("%s\n", szTemp);
  53. return dwErr;
  54. }
  55. void
  56. Usage(char* pszExe)
  57. {
  58. printf("\n");
  59. printf("Tool for cleaning up ACEs added by Windows 2000 Beta3 and RC1 setup\n");
  60. printf("to grant user account access to legacy RAS servers.\n");
  61. printf("\n");
  62. printf("Usage\n");
  63. printf("\t%s -d <domain>\n", pszExe);
  64. printf("\n");
  65. }
  66. int __cdecl main(int argc, char** argv)
  67. {
  68. DWORD dwErr = NO_ERROR, iErr = 0;
  69. WCHAR pszDomain[512];
  70. int iSize = sizeof(pszDomain) / sizeof(WCHAR);
  71. if (argc != 3)
  72. {
  73. Usage(argv[0]);
  74. return 0;
  75. }
  76. if (strcmp(argv[1], "-d") != 0)
  77. {
  78. Usage(argv[0]);
  79. return 0;
  80. }
  81. // Parse out the domain
  82. //
  83. iErr = MultiByteToWideChar(CP_ACP, 0, argv[2], -1, pszDomain, iSize);
  84. if (iErr == 0)
  85. {
  86. printf("Unable to convert %s to unicode.\n", argv[2]);
  87. printf("Error: 0x%x\n", GetLastError());
  88. return 0;
  89. }
  90. // Set the access
  91. //
  92. DsrTraceInit();
  93. dwErr = DsrDomainSetAccess(pszDomain, 0);
  94. DsrTraceCleanup();
  95. // Display results
  96. //
  97. if (dwErr == NO_ERROR)
  98. {
  99. printf("Success.\n");
  100. }
  101. else
  102. {
  103. printf("Error.\n");
  104. }
  105. return 0;
  106. }