我正在研究一个典型的Windows架构,包含DC,Exchange服务器等等。
最近,我设置了一个脚本,在用户被locking时收到通知。 它工作正常,但是我注意到一些非常奇怪的东西。
我报告了几个信息,比如用户被locking的机器,负责操作的DC等等(我可以在DC上login所有这些信息,ID 4740用于locking,4767用于解锁)。
事情是,经常(大约每天1或2),一些用户被locking从域控制器(如他在这个DC多次失败的密码)。 当然,用户不能访问DC,所以这是第一个奇怪的事情。 更奇怪的是,这些用户在1秒钟后被pipe理员自动解锁。
你知道什么可能导致这个? 我很确定它不能是任何恶意的东西。
注意 :
谢谢你的时间 ! 🙂
这里是脚本的代码(但我不认为它可以是任何用途)
#Get security user lockout events. 61 seconds should be sufficient, as the scheduled task run every minute. #It leaves 1 sec for execution time. #EventID 4740 is user lockout. 4767 is unlock. $startTime = (get-date).addseconds(-61) [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $DomainControllers = (Get-ADDomainController -Filter *) foreach ($DC in $DomainControllers) { $eventList = Get-WinEvent -ComputerName $DC.Name -filterhashtable @{logname="security";starttime=$startTime;id="4740"} -ErrorAction SilentlyContinue $emailBody = $null if ($eventList) { #Start a walk through the events to collect data. $eventList | foreach-object { [string]$lockoutTime = $_.timecreated $userName = $_.Properties[0].Value $user = Get-ADUser -Identity $userName -Properties * $name = $user.Name $department = $user.Department $site = $user.City $mail = $user.PrimarySmtpAddress $userSID = $_.Properties[2].Value $computerName = $_.Properties[1].Value -creplace '^\\+','' $IPAddress = [System.Net.Dns]::GetHostAddresses($computerName).IPAddressToString #Compile the alert text from each event $emailBody += "Utilisateur : $name`nDepartment : $department`nSite : $site`nLogin : $userName`nEmail : $mail`nOrdinateur fautif : $computerName`nAdresses IP : $IPAddress`nDate de verrouillage : $lockoutTime`nDC responsable du verrouillage : $($DC.Name)`nSID de l'utilisateur : $userSID" #Send mail to report the lockout Send-MailMessage -To "<####>" -From "<####>" -Subject "Blocage compte AD" -Body $emailBody -SmtpServer "####" #Create a popup on desktop $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Unlocked AD accounts" $objForm.Size = New-Object System.Drawing.Size(300,115) $objForm.StartPosition = "CenterScreen" $objLabel = New-Object System.Windows.Forms.Label $objLabel.Size = New-Object System.Drawing.Size(280,20) $objLabel.Location = New-Object System.Drawing.Size(10,15) $objLabel.Text = "Compte de $name verrouillé." $objForm.Controls.Add($objLabel) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(160,50) $OKButton.Size = New-Object System.Drawing.Size(85,23) $OKButton.Text = "Tant pis" $OKButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($OKButton) $UnlockButton = New-Object System.Windows.Forms.Button $UnlockButton.Location = New-Object System.Drawing.Size(60,50) $UnlockButton.Size = New-Object System.Drawing.Size(85,23) $UnlockButton.Text = "Déverrouiller" $UnlockButton.Add_Click({Unlock-ADAccount $userName; $objForm.Close()}) $objForm.Controls.Add($UnlockButton) if ((Get-ADUser $userName -Properties Lockedout).Lockedout) { [void] $objForm.ShowDialog() } } } }