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.

171 lines
7.0 KiB

  1. VERSION 5.00
  2. Begin VB.Form Form1
  3. Caption = "Form1"
  4. ClientHeight = 3195
  5. ClientLeft = 60
  6. ClientTop = 345
  7. ClientWidth = 4680
  8. LinkTopic = "Form1"
  9. ScaleHeight = 3195
  10. ScaleWidth = 4680
  11. StartUpPosition = 3 'Windows Default
  12. End
  13. Attribute VB_Name = "Form1"
  14. Attribute VB_GlobalNameSpace = False
  15. Attribute VB_Creatable = False
  16. Attribute VB_PredeclaredId = True
  17. Attribute VB_Exposed = False
  18. Private Sub Form_Load()
  19. On Error Resume Next
  20. Dim Locator As New SWbemLocator
  21. Dim Service As SWbemServices
  22. Set Service = Locator.ConnectServer("ludlow")
  23. Debug.Print "Service initial settings:"
  24. Debug.Print "Authentication: " & Service.Security_.AuthenticationLevel
  25. Debug.Print "Impersonation: " & Service.Security_.ImpersonationLevel; ""
  26. Debug.Print ""
  27. Service.Security_.AuthenticationLevel = wbemAuthenticationLevelConnect
  28. Service.Security_.ImpersonationLevel = wbemImpersonationLevelIdentify
  29. Debug.Print "Service modified settings (expecting {2,2}):"
  30. Debug.Print "Authentication: " & Service.Security_.AuthenticationLevel
  31. Debug.Print "Impersonation: " & Service.Security_.ImpersonationLevel; ""
  32. Debug.Print ""
  33. 'Now get a class
  34. Dim Class As SWbemObject
  35. Set Class = Service.Get("Win32_LogicalDisk")
  36. Debug.Print "Class initial settings (expecting {2,2}):"
  37. Debug.Print "Authentication: " & Class.Security_.AuthenticationLevel
  38. Debug.Print "Impersonation: " & Class.Security_.ImpersonationLevel; ""
  39. Debug.Print ""
  40. Class.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
  41. Class.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
  42. Debug.Print "Class modified settings (expecting {6,3}):"
  43. Debug.Print "Authentication: " & Class.Security_.AuthenticationLevel
  44. Debug.Print "Impersonation: " & Class.Security_.ImpersonationLevel; ""
  45. Debug.Print ""
  46. 'Now get an enumeration from the object
  47. Dim Disks As SWbemObjectSet
  48. Set Disks = Class.Instances_
  49. Debug.Print "Collection A initial settings (expecting {6,3}):"
  50. Debug.Print "Authentication: " & Disks.Security_.AuthenticationLevel
  51. Debug.Print "Impersonation: " & Disks.Security_.ImpersonationLevel; ""
  52. Debug.Print ""
  53. 'For grins print them out
  54. Dim Disk As SWbemObject
  55. For Each Disk In Disks
  56. Debug.Print Disk.Path_.DisplayName
  57. Debug.Print Disk.Security_.AuthenticationLevel & ":" & Disk.Security_.ImpersonationLevel
  58. Next
  59. Debug.Print ""
  60. Disks.Security_.AuthenticationLevel = wbemAuthenticationLevelPkt
  61. Disks.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
  62. Debug.Print "Collection A modified settings (expecting {4,1}):"
  63. Debug.Print "Authentication: " & Disks.Security_.AuthenticationLevel
  64. Debug.Print "Impersonation: " & Disks.Security_.ImpersonationLevel; ""
  65. Debug.Print ""
  66. 'Now get an enumeration from the service
  67. Dim Services As SWbemObjectSet
  68. Set Services = Service.InstancesOf("Win32_service")
  69. Debug.Print "Collection B initial settings (expecting {2,2}):"
  70. Debug.Print "Authentication: " & Services.Security_.AuthenticationLevel
  71. Debug.Print "Impersonation: " & Services.Security_.ImpersonationLevel; ""
  72. Debug.Print ""
  73. 'For grins print them out
  74. Dim MyService As SWbemObject
  75. For Each MyService In Services
  76. Debug.Print MyService.Path_.DisplayName
  77. Debug.Print MyService.Security_.AuthenticationLevel & ":" & MyService.Security_.ImpersonationLevel
  78. Next
  79. Debug.Print ""
  80. Services.Security_.AuthenticationLevel = wbemAuthenticationLevelCall
  81. Services.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
  82. Debug.Print "Collection B modified settings (expecting {3,4} or {4,4}):"
  83. Debug.Print "Authentication: " & Services.Security_.AuthenticationLevel
  84. Debug.Print "Impersonation: " & Services.Security_.ImpersonationLevel; ""
  85. Debug.Print ""
  86. 'Print out again as settings should have changed
  87. For Each MyService In Services
  88. Debug.Print MyService.Path_.DisplayName
  89. Debug.Print MyService.Security_.AuthenticationLevel & ":" & MyService.Security_.ImpersonationLevel
  90. Next
  91. Debug.Print ""
  92. 'Now get an event source
  93. Dim Events As SWbemEventSource
  94. Set Events = Service.ExecNotificationQuery _
  95. ("select * from __instancecreationevent where targetinstance isa 'Win32_NTLogEvent'")
  96. Debug.Print "Event Source initial settings (expecting {2,3}):"
  97. Debug.Print "Authentication: " & Events.Security_.AuthenticationLevel
  98. Debug.Print "Impersonation: " & Events.Security_.ImpersonationLevel; ""
  99. Debug.Print ""
  100. Events.Security_.AuthenticationLevel = wbemAuthenticationLevelPktIntegrity
  101. Events.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate
  102. Debug.Print "Event Source modified settings (expecting {5,4}):"
  103. Debug.Print "Authentication: " & Events.Security_.AuthenticationLevel
  104. Debug.Print "Impersonation: " & Events.Security_.ImpersonationLevel; ""
  105. Debug.Print ""
  106. 'Now generate an error from services
  107. On Error Resume Next
  108. Dim MyError As SWbemLastError
  109. Dim Class2 As SWbemObject
  110. Set Class2 = Service.Get("NoSuchClassss")
  111. If Err <> 0 Then
  112. Set MyError = New WbemScripting.SWbemLastError
  113. Debug.Print "ERROR: " & Err.Description & "," & Err.Number & "," & Err.Source
  114. Debug.Print MyError.Security_.AuthenticationLevel
  115. Debug.Print MyError.Security_.ImpersonationLevel
  116. Err.Clear
  117. End If
  118. Debug.Print "FINAL SETTINGS"
  119. Debug.Print "=============="
  120. Debug.Print ""
  121. Debug.Print "Service settings (expected {2,3}) = {" & Service.Security_.AuthenticationLevel _
  122. & "," & Service.Security_.ImpersonationLevel & "}"
  123. Debug.Print ""
  124. Debug.Print "Class settings (expected {6,2}) = {" & Class.Security_.AuthenticationLevel _
  125. & "," & Class.Security_.ImpersonationLevel & "}"
  126. Debug.Print ""
  127. Debug.Print "Collection A settings (expected {4,1}) = {" & Disks.Security_.AuthenticationLevel _
  128. & "," & Disks.Security_.ImpersonationLevel & "}"
  129. Debug.Print ""
  130. Debug.Print "Collection B settings (expected {4,4} or {3,4}) = {" & Services.Security_.AuthenticationLevel _
  131. & "," & Services.Security_.ImpersonationLevel & "}"
  132. Debug.Print ""
  133. Debug.Print "Event Source settings (expected {5,4}) = {" & Events.Security_.AuthenticationLevel _
  134. & "," & Events.Security_.ImpersonationLevel & "}"
  135. If Err <> 0 Then
  136. Debug.Print "ERROR: " & Err.Description & "," & Err.Number & "," & Err.Source
  137. End If
  138. Debug.Print Services.Count & "+" & Disks.Count
  139. End Sub