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