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.

85 lines
2.0 KiB

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