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.

84 lines
1.9 KiB

  1. ' clonelg.vbt start
  2. ' CloneSecurityPrincipal VBScript
  3. '
  4. ' Clone all Local Groups 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 = "clonelg.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 local group and is not well known group
  25. function ShouldCloneObject(byref srcObject)
  26. on error resume next
  27. if ObjectClass(srcObject) = CLASS_LOCAL_GROUP then
  28. ' determine if the group is a well known
  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. ' clonelg.vbt end