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.

103 lines
2.7 KiB

  1. on error resume next
  2. set l = CreateObject("WbemScripting.SWbemLocatorEx")
  3. set c = CreateObject("WbemScripting.SWbemNamedValueSet")
  4. set ldap = l.Open ("umi://nw01t1/ldap", "nw01t1domnb\administrator", "nw01t1domnb")
  5. Set objArgs = Wscript.Arguments
  6. if objArgs.Count > 0 then
  7. if objArgs(0) = "?" OR objArgs(0) = "/?" OR objArgs(0) = "h" OR objArgs(0) = "/h" _
  8. OR objArgs(0) = "-?" OR objArgs(0) = "-h" then
  9. WScript.Echo "Usage: cscript sd.vbs [[o][g][d][s]]"
  10. WScript.Quit
  11. end if
  12. if InStr( 1, objArgs(0), "o", 1) > 0 then c.Add "INCLUDE_OWNER", true
  13. if InStr( 1, objArgs(0), "g", 1) > 0 then c.Add "INCLUDE_GROUP", true
  14. if InStr( 1, objArgs(0), "d", 1) > 0 then c.Add "INCLUDE_DACL", true
  15. if InStr( 1, objArgs(0), "s", 1) > 0 then c.Add "INCLUDE_SACL", true
  16. else
  17. c.Add "INCLUDE_GROUP", true
  18. c.Add "INCLUDE_OWNER", true
  19. c.Add "INCLUDE_DACL", true
  20. c.Add "INCLUDE_SACL", true
  21. end if
  22. set cont = ldap.Get (".CN=users", &H40000, c)
  23. set sd = cont.GetSecurityDescriptor_
  24. if err then WScript.Echo "[" & Err.Description & "]"
  25. WScript.Echo
  26. WScript.Echo "SD"
  27. WScript.Echo "=="
  28. WScript.Echo
  29. WScript.Echo "Revision:", sd.Revision
  30. WScript.Echo "Control:", sd.Control
  31. WScript.Echo "Owner:", sd.Owner
  32. WScript.Echo "OwnerDefaulted:", sd.OwnerDefaulted
  33. WScript.Echo "Group:", sd.Group
  34. WScript.Echo "GroupDefaulted:", sd.GroupDefaulted
  35. WScript.Echo "DaclDefaulted:", sd.DaclDefaulted
  36. WScript.Echo "SaclDefaulted:", sd.SaclDefaulted
  37. set dacl = sd.DiscretionaryAcl
  38. WScript.Echo
  39. WScript.Echo "DACL"
  40. WScript.Echo "===="
  41. WScript.Echo
  42. DisplayACL dacl
  43. set sacl = sd.SystemAcl
  44. WScript.Echo
  45. WScript.Echo "SACL"
  46. WScript.Echo "===="
  47. WScript.Echo
  48. DisplayACL sacl
  49. Sub DisplayAcl (acl)
  50. on error resume next
  51. ' NOTE: The following test should really be IsObject, but
  52. ' for some reason using [ogd] we don't get a nothing back from the
  53. ' IADsSecurityDescriptor.SystemAcl and DiscretionaryAcl calls, we get what
  54. ' looks like VT_NULL.
  55. '
  56. ' We can change this to use IsNull instead to fix that test, but then
  57. ' the [o] test fails here with "Object Required". It seems that sometimes
  58. ' the omission of the ACL from the SD is marked with a VT_NULL and sometimes
  59. ' is literally marked as "Nothing".
  60. if IsObject(acl) then
  61. if Not acl is Nothing then
  62. if err <> 0 then
  63. WScript.Echo "No ACL Present"
  64. else
  65. Wscript.Echo "AceCount:", acl.AceCount
  66. WScript.Echo "AclRevision:", acl.AclRevision
  67. for each ace in acl
  68. DisplayAce ace
  69. next
  70. end if
  71. else
  72. WScript.Echo "No ACL Present"
  73. end if
  74. else
  75. WScript.Echo "No ACL Present"
  76. end if
  77. End Sub
  78. Sub DisplayAce (ace)
  79. on error resume next
  80. WScript.Echo " " & Hex(ace.AccessMask) & " " & ace.AceType & " " & ace.Trustee
  81. End Sub