Dev*_*ULL 0 windows-server-2008 domain user-management
如何阻止用户在本地登录并强制他们登录域。一些用户仍在本地登录,这是我们最近转换之前使用的。我需要立即停止这件事。
域控制器是 Windows 2008 Server,每个工作站(除了一个是 Windows 7 Pro)都运行 Windows XP SP3。
处理此问题的最佳方法是从受影响的客户端计算机中删除本地用户帐户。如果用户知道这些机器上的本地“管理员”密码,请更改它。
但是,如果用户的域帐户在客户端计算机上具有“管理员”权限,则他们可以创建更多本地用户帐户。
如果您不想手动执行此工作,则可以通过启动脚本执行此操作。这是删除本地用户帐户的脚本:
Option Explicit
Dim dictUsersToIgnore, objNetwork
Dim colSourceAccounts, objSourceUser
' Debugging
Const DEBUGGING = True
' Source and destination computers
Const SOURCE_COMPUTER = "."
' Constants for comparison of accounts to ignore list
Const MATCH_EXACT = 1
Const MATCH_LEFT = 2
' Accounts to ignore during copying
Set dictUsersToIgnore = CreateObject("Scripting.Dictionary")
dictUsersToIgnore.Add "SUPPORT_", MATCH_LEFT
dictUsersToIgnore.Add "IUSR_", MATCH_LEFT
dictUsersToIgnore.Add "IWAM_", MATCH_LEFT
dictUsersToIgnore.Add "Administrator", MATCH_EXACT
dictUsersToIgnore.Add "Guest", MATCH_EXACT
dictUsersToIgnore.Add "HelpAssistant", MATCH_EXACT
dictUsersToIgnore.Add "ASPNET", MATCH_EXACT
' Should this account be ignored
Function IgnoreObject(Name, dictNames)
Dim strToIgnore
IgnoreObject = False
For Each strToIgnore in dictNames
' Match Exact
If (dictNames.Item(strToIgnore) = MATCH_EXACT) and (UCase(Name) = UCase(strToIgnore)) Then
IgnoreObject = True
Exit Function
End If
' Match left
If (dictNames.Item(strToIgnore) = MATCH_LEFT) and (Left(UCase(Name), Len(strToIgnore)) = UCase(strToIgnore)) Then
IgnoreObject = True
Exit Function
End If
Next' strToIgnore
End Function
Set objNetwork = CreateObject("Wscript.Network")
' Get accounts on source computer and loop through them, copying as necessary
Set colSourceAccounts = GetObject("WinNT://" & SOURCE_COMPUTER)
colSourceAccounts.Filter = Array("user")
For Each objSourceUser In colSourceAccounts
If IgnoreObject(objSourceUser.Name, dictUsersToIgnore) = False Then
If (DEBUGGING) Then WScript.Echo "Deleting account: " & objSourceUser.Name
colSourceAccounts.Delete "user", objSourceUser.Name
Else
If (DEBUGGING) Then WScript.Echo "Ignoring account: " & objSourceUser.Name
End If
Next ' objSourceUser
Run Code Online (Sandbox Code Playgroud)
将不应删除的任何用户名添加到 dictUsersToIgnore 列表中。MATCH_EXACT 表示用户名完全匹配。MATCH_LEFT 意味着只匹配用户名的最左边部分(即想象名称匹配后面有一个“*”)。
该脚本适合作为AD启动脚本使用。小心你的范围——如果你在错误的地方运行它,它真的会毁了你的一天。
| 归档时间: |
|
| 查看次数: |
980 次 |
| 最近记录: |