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.

173 lines
4.3 KiB

  1. on error resume next
  2. while true
  3. '***********************************************************
  4. 'First pass - create an ISWbemServices object with "default"
  5. 'impersonation level
  6. '***********************************************************
  7. set service = GetObject("winmgmts:")
  8. select case service.security_.impersonationlevel
  9. case 1
  10. ImpLevel = "Anonymous"
  11. case 2
  12. ImpLevel = "Identify"
  13. case 3
  14. ImpLevel = "Impersonate"
  15. case 4
  16. ImpLevel = "Delegate"
  17. end select
  18. WScript.Echo ""
  19. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  20. WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
  21. & ImpLevel
  22. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  23. WScript.Echo ""
  24. for each Process in service.InstancesOf ("win32_process")
  25. WScript.Echo Process.ProcessId, Process.name
  26. next
  27. if err <> 0 then
  28. WScript.Echo "*** FAILED - as expected ***"
  29. err.clear
  30. else
  31. WScript.Echo "*** SUCCEEDED - error ***"
  32. end if
  33. '****************************************************************
  34. 'Second pass - create an ISWbemServices object with Impersonation
  35. '"enabled"
  36. '****************************************************************
  37. set service = GetObject("winmgmts:{impersonationLevel=impersonate}")
  38. select case service.security_.impersonationlevel
  39. case 1
  40. ImpLevel = "Anonymous"
  41. case 2
  42. ImpLevel = "Identify"
  43. case 3
  44. ImpLevel = "Impersonate"
  45. case 4
  46. ImpLevel = "Delegate"
  47. end select
  48. WScript.Echo ""
  49. WScript.Echo ""
  50. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  51. WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
  52. & ImpLevel
  53. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  54. WScript.Echo ""
  55. for each Process in service.InstancesOf ("win32_process")
  56. WScript.Echo Process.ProcessId, Process.name
  57. next
  58. WScript.Echo ""
  59. if err <> 0 then
  60. WScript.Echo "*** FAILED - error ***"
  61. else
  62. WScript.Echo "*** SUCCEEDED - as expected ***"
  63. err.clear
  64. end if
  65. '****************************************************************
  66. 'Third pass - create an ISWbemServices object with Impersonation
  67. '"anonymous"
  68. '****************************************************************
  69. set service = GetObject("winmgmts:{impersonationLevel=anonymous}")
  70. select case service.security_.impersonationlevel
  71. case 1
  72. ImpLevel = "Anonymous"
  73. case 2
  74. ImpLevel = "Identify"
  75. case 3
  76. ImpLevel = "Impersonate"
  77. case 4
  78. ImpLevel = "Delegate"
  79. end select
  80. WScript.Echo ""
  81. WScript.Echo ""
  82. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  83. WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
  84. & ImpLevel
  85. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  86. WScript.Echo ""
  87. for each Process in service.InstancesOf ("win32_process")
  88. WScript.Echo Process.ProcessId, Process.name
  89. next
  90. WScript.Echo ""
  91. if err <> 0 then
  92. WScript.Echo "*** FAILED - as expected ***"
  93. err.clear
  94. else
  95. WScript.Echo "*** SUCCEEDED - error ***"
  96. end if
  97. '****************************************************************
  98. 'Third pass - create an ISWbemServices object with Impersonation
  99. '"delegate"
  100. '****************************************************************
  101. set service = GetObject("winmgmts:{impersonationLevel=delegate}")
  102. select case service.security_.impersonationlevel
  103. case 1
  104. ImpLevel = "Anonymous"
  105. case 2
  106. ImpLevel = "Identify"
  107. case 3
  108. ImpLevel = "Impersonate"
  109. case 4
  110. ImpLevel = "Delegate"
  111. end select
  112. WScript.Echo ""
  113. WScript.Echo ""
  114. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  115. WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
  116. & ImpLevel
  117. WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  118. WScript.Echo ""
  119. for each Process in service.InstancesOf ("win32_process")
  120. WScript.Echo Process.ProcessId, Process.name
  121. next
  122. WScript.Echo ""
  123. if err <> 0 then
  124. WScript.Echo "*** FAILED - as expected ***"
  125. err.clear
  126. else
  127. WScript.Echo "*** SUCCEEDED - error ***"
  128. end if
  129. wend