Source code of Windows XP (NT5)
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.

78 lines
1.8 KiB

  1. ' clonegg.vbt start
  2. ' CloneSecurityPrincipal VBScript
  3. '
  4. ' Clone all Global Groups in a domain
  5. '
  6. ' Copyright (C) 1999 Microsoft Corporation.
  7. option explicit
  8. const SCRIPT_FILENAME = "clonegg.vbs"
  9. const SCRIPT_SOURCE_NAME = __FILE__
  10. const SCRIPT_DATE = __DATE__
  11. const SCRIPT_TIME = __TIME__
  12. // this is a Visual Basic Script "Template", used in conjunction with the
  13. // MS Visual C++ Preprocessor to overcome some of the source management
  14. // limitations of VBScript. Not perfect, but better than a stick in the eye.
  15. //
  16. // use cl /EP foo.vbt > foo.vbs to expand the template
  17. // this is all our common code.
  18. #include "clonepr.vbi"
  19. // code common to the scripts that operate on all domain accounts. We
  20. // supply our own definition of ShouldCloneObject. For every object for
  21. // which we return True, that object is cloned.
  22. #include "clonedom.vbi"
  23. Main
  24. wscript.quit(0)
  25. ' returns True if the object is a global group and not WellKnown Group
  26. function ShouldCloneObject(byref srcObject)
  27. on error resume next
  28. if ObjectClass(srcObject) = CLASS_GLOBAL_GROUP then
  29. sid.SetAs ADS_SID_WINNT_PATH, srcObject.AdsPath & "," & srcObject.Class
  30. if Err.Number then DumpErrAndQuit
  31. dim sidString
  32. sidString = sid.GetAs(ADS_SID_SDDL)
  33. if Err.Number then DumpErrAndQuit
  34. 'To Stop Cloning Well Known Sids Uncomment 4 lines below
  35. ' if HasWellKnownRid(sidString) then
  36. ' ShouldCloneObject = False
  37. ' exit function
  38. ' end if
  39. if IsBuiltInSid( sidString ) then
  40. Echo srcObject.Name & " is a builtin Account."
  41. Echo "BuiltIn Users and Groups cannot be cloned"
  42. ShouldCloneObject = False
  43. exit function
  44. end if
  45. ShouldCloneObject = True
  46. exit function
  47. end if
  48. ShouldCloneObject = False
  49. end function
  50. ' clonegg.vbt end