mirror of https://github.com/tongzx/nt5src
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
85 lines
2.0 KiB
' cloneggu.vbt start
|
|
|
|
' CloneSecurityPrincipal VBScript
|
|
'
|
|
' Clone all Global Groups and Users in a domain
|
|
'
|
|
' Copyright (C) 1999 Microsoft Corporation.
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
|
|
|
const SCRIPT_FILENAME = "cloneggu.vbs"
|
|
const SCRIPT_SOURCE_NAME = __FILE__
|
|
const SCRIPT_DATE = __DATE__
|
|
const SCRIPT_TIME = __TIME__
|
|
|
|
|
|
|
|
|
|
// 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 a well-known account
|
|
|
|
function ShouldCloneObject(byref srcObject)
|
|
on error resume next
|
|
|
|
dim srcObjectClass
|
|
srcObjectClass = ObjectClass(srcObject)
|
|
if srcObjectClass = CLASS_GLOBAL_GROUP OR srcObjectClass = CLASS_USER then
|
|
|
|
' determine if the object is well-known
|
|
|
|
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
|
|
|
|
|
|
|
|
' cloneggu.vbt end
|