windows-nt/Source/XPSP1/NT/admin/dsutils/migrate/scripts/clonegg.vbt

79 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-09-26 03:20:57 -05:00
' clonegg.vbt start
' CloneSecurityPrincipal VBScript
'
' Clone all Global Groups in a domain
'
' Copyright (C) 1999 Microsoft Corporation.
option explicit
const SCRIPT_FILENAME = "clonegg.vbs"
const SCRIPT_SOURCE_NAME = __FILE__
const SCRIPT_DATE = __DATE__
const SCRIPT_TIME = __TIME__
// this is a Visual Basic Script "Template", used in conjunction with the
// MS Visual C++ Preprocessor to overcome some of the source management
// limitations of VBScript. Not perfect, but better than a stick in the eye.
//
// use cl /EP foo.vbt > foo.vbs to expand the template
// this is all our common code.
#include "clonepr.vbi"
// code common to the scripts that operate on all domain accounts. We
// supply our own definition of ShouldCloneObject. For every object for
// which we return True, that object is cloned.
#include "clonedom.vbi"
Main
wscript.quit(0)
' returns True if the object is a global group and not WellKnown Group
function ShouldCloneObject(byref srcObject)
on error resume next
if ObjectClass(srcObject) = CLASS_GLOBAL_GROUP then
sid.SetAs ADS_SID_WINNT_PATH, srcObject.AdsPath & "," & srcObject.Class
if Err.Number then DumpErrAndQuit
dim sidString
sidString = sid.GetAs(ADS_SID_SDDL)
if Err.Number then DumpErrAndQuit
'To Stop Cloning Well Known Sids Uncomment 4 lines below
' if HasWellKnownRid(sidString) then
' ShouldCloneObject = False
' exit function
' end if
if IsBuiltInSid( sidString ) then
Echo srcObject.Name & " is a builtin Account."
Echo "BuiltIn Users and Groups cannot be cloned"
ShouldCloneObject = False
exit function
end if
ShouldCloneObject = True
exit function
end if
ShouldCloneObject = False
end function
' clonegg.vbt end