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.

128 lines
5.8 KiB

  1. var Locator = new ActiveXObject("WbemScripting.SWbemLocator");
  2. var Service = Locator.ConnectServer();
  3. WScript.Echo ("Service initial settings:");
  4. WScript.Echo ("Authentication: " + Service.Security_.AuthenticationLevel);
  5. WScript.Echo ("Impersonation: " + Service.Security_.ImpersonationLevel );
  6. WScript.Echo ();
  7. Service.Security_.AuthenticationLevel = 2; //wbemAuthenticationLevelConnect
  8. Service.Security_.ImpersonationLevel = 3; //wbemImpersonationLevelImpersonate
  9. WScript.Echo ("Service modified settings (expecting {2,3}):");
  10. WScript.Echo ("Authentication: " + Service.Security_.AuthenticationLevel);
  11. WScript.Echo ("Impersonation: " + Service.Security_.ImpersonationLevel);
  12. WScript.Echo ();
  13. //Now get a class
  14. var Class = Service.Get("Win32_LogicalDisk");
  15. WScript.Echo ("Class initial settings (expecting {2,3}):");
  16. WScript.Echo ("Authentication: " + Class.Security_.AuthenticationLevel);
  17. WScript.Echo ("Impersonation: " + Class.Security_.ImpersonationLevel);
  18. WScript.Echo ();
  19. Class.Security_.AuthenticationLevel = 6; //wbemAuthenticationLevelPktPrivacy
  20. Class.Security_.ImpersonationLevel = 3; //wbemImpersonationLevelIdentify
  21. WScript.Echo ("Class modified settings (expecting {6,3}):");
  22. WScript.Echo ("Authentication: " + Class.Security_.AuthenticationLevel);
  23. WScript.Echo ("Impersonation: " + Class.Security_.ImpersonationLevel);
  24. WScript.Echo ();
  25. //Now get an enumeration from the object
  26. var Disks = Class.Instances_();
  27. WScript.Echo ("Collection A initial settings (expecting {6,3}):");
  28. WScript.Echo ("Authentication: " + Disks.Security_.AuthenticationLevel);
  29. WScript.Echo ("Impersonation: " + Disks.Security_.ImpersonationLevel);
  30. WScript.Echo ();
  31. //For grins print them out
  32. for (var e = new Enumerator (Disks); !e.atEnd(); e.moveNext())
  33. {
  34. var Disk = e.item ();
  35. WScript.Echo (Disk.Path_.DisplayName);
  36. WScript.Echo (Disk.Security_.AuthenticationLevel + ":" + Disk.Security_.ImpersonationLevel);
  37. }
  38. WScript.Echo ();
  39. Disks.Security_.AuthenticationLevel = 4; //wbemAuthenticationLevelPkt
  40. Disks.Security_.ImpersonationLevel = 1; //wbemImpersonationLevelAnonymous
  41. WScript.Echo ("Collection A modified settings (expecting {4,1}):");
  42. WScript.Echo ("Authentication: " + Disks.Security_.AuthenticationLevel);
  43. WScript.Echo ("Impersonation: " + Disks.Security_.ImpersonationLevel);
  44. WScript.Echo ();
  45. //Now get an enumeration from the service
  46. var Services = Service.InstancesOf("Win32_service");
  47. WScript.Echo ("Collection B initial settings (expecting {2,3}):");
  48. WScript.Echo ("Authentication: " + Services.Security_.AuthenticationLevel);
  49. WScript.Echo ("Impersonation: " + Services.Security_.ImpersonationLevel);
  50. WScript.Echo ();
  51. //For grins print them out
  52. for (var e = new Enumerator (Services); !e.atEnd(); e.moveNext())
  53. {
  54. var MyService = e.item ();
  55. WScript.Echo (MyService.Path_.DisplayName);
  56. WScript.Echo (MyService.Security_.AuthenticationLevel + ":" + MyService.Security_.ImpersonationLevel);
  57. }
  58. WScript.Echo ();
  59. Services.Security_.AuthenticationLevel = 3; //wbemAuthenticationLevelCall
  60. Services.Security_.ImpersonationLevel = 4; //wbemImpersonationLevelDelegate
  61. WScript.Echo ("Collection B modified settings (expecting {3,4} or {4,4}):");
  62. WScript.Echo ("Authentication: " + Services.Security_.AuthenticationLevel);
  63. WScript.Echo ("Impersonation: " + Services.Security_.ImpersonationLevel);
  64. WScript.Echo ();
  65. //Print out again as settings should have changed
  66. for (var e = new Enumerator (Services); !e.atEnd(); e.moveNext())
  67. {
  68. var MyService = e.item ();
  69. WScript.Echo (MyService.Path_.DisplayName);
  70. WScript.Echo (MyService.Security_.AuthenticationLevel + ":" + MyService.Security_.ImpersonationLevel);
  71. }
  72. //Now get an event source
  73. var Events = Service.ExecNotificationQuery
  74. ("select * from __instancecreationevent where targetinstance isa 'Win32_NTLogEvent'");
  75. WScript.Echo ("Event Source initial settings (expecting {2,3}):");
  76. WScript.Echo ("Authentication: " + Events.Security_.AuthenticationLevel);
  77. WScript.Echo ("Impersonation: " + Events.Security_.ImpersonationLevel);
  78. WScript.Echo ();
  79. Events.Security_.AuthenticationLevel = 5; //wbemAuthenticationLevelPktIntegrity
  80. Events.Security_.ImpersonationLevel = 4; //wbemImpersonationLevelDelegate
  81. WScript.Echo ("Event Source modified settings (expecting {5,4}):");
  82. WScript.Echo ("Authentication: " + Events.Security_.AuthenticationLevel);
  83. WScript.Echo ("Impersonation: " + Events.Security_.ImpersonationLevel);
  84. WScript.Echo ();
  85. WScript.Echo ("FINAL SETTINGS");
  86. WScript.Echo ("==============\n");
  87. WScript.Echo ("Service settings (expected {2,3}) = {" + Service.Security_.AuthenticationLevel
  88. + "," + Service.Security_.ImpersonationLevel + "}\n");
  89. WScript.Echo ("Class settings (expected {6,3}) = {" + Class.Security_.AuthenticationLevel
  90. + "," + Class.Security_.ImpersonationLevel + "}\n");
  91. WScript.Echo ("Collection A settings (expected {4,1}) = {" + Disks.Security_.AuthenticationLevel
  92. + "," + Disks.Security_.ImpersonationLevel + "}\n");
  93. WScript.Echo ("Collection B settings (expected {4,4} or {3,4}) = {" + Services.Security_.AuthenticationLevel
  94. + "," + Services.Security_.ImpersonationLevel + "}\n");
  95. WScript.Echo ("Event Source settings (expected {5,4}) = {" + Events.Security_.AuthenticationLevel
  96. + "," + Events.Security_.ImpersonationLevel + "}\n");
  97. WScript.Echo (Services.Count);