'==========================================================================
'
' NAME: RestrictedLogon.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYRIGHT (c) 2005 All Rights Reserved
' DATE : 9/25/2005
'
' COMMENT: Assumes the PC name is equal to the user name that is allowed to log on to the PC
'
'==========================================================================
On Error Resume Next
Dim WSHShell, WSHNetwork, Partition, Partitions
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("Wscript.Network")
pcName = WSHNetwork.Computername
Set Partitions = GetObject("LDAP://CN=Partitions,CN=Configuration," & _
GetObject("LDAP://RootDSE").Get("DefaultNamingContext"))
On Error Resume Next
For Each Partition In Partitions
strDomain = Partition.Get("nETBIOSName")
If Err.Number = 0 then Exit For
Next
Set Partitions = Nothing
Call WSHShell.Run(net localgroup users " & strDomain & "\" & pcName & " /add")
Call WSHShell.Run(net localgroup users " & strDomain & "\Administrator" & " /add")
Call WSHShell.Run(net localgroup users " & strDomain & "\Domain Admins" & " /add")
Call WSHShell.Run(net localgroup users " & strDomain & "\Domain Users" & " /remove")