Jump to content
Sign in to follow this  
stamandster

Locked Domain User Notifier

Recommended Posts

Simple tool to run in the user context to notify them that they are locked out of the network. The notification window will go away once the user is locked out. The notification window is transparent and click-through able. Will work even if logged into multiple workstations.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=135853869.ico
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <array.au3>
#include <string.au3>
#include <Array.au3>
#include <WinAPIShPath.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

GLOBAL $NotificationTitle = "IT WARNING!"
GLOBAL $tR = 0
GLOBAL $hC, $hP
GLOBAL $fRun = 0
GLOBAL $wbemFlagReturnImmediately = 0x10
GLOBAL $wbemFlagForwardOnly = 0x20
GLOBAL $strComputer = "localhost"
GLOBAL $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")



While 1
    sleep(30000)
    $LockOutStatus = _Query_WMI_Lockout_Status()

    Select
        Case Stringinstr($LockOutStatus,"False")
            consolewrite($LockOutStatus &" -_- "& $tR & @CRLF)
            GLOBAL $tR = 0
            _NotificationPrompt(false)

        Case Stringinstr($LockOutStatus,"True") AND $tR = 0
            consolewrite($LockOutStatus &" -_- "& $tR & @CRLF)
            GLOBAL $tR = 1
            _NotificationPrompt(true)

        Case Else
            consolewrite("Still " & $LockOutStatus &" -_- "& $tR & @CRLF)

    EndSelect
WEnd




Func _Query_WMI_Lockout_Status()

    $colItems = ""
    $colItems = $objWMIService.ExecQuery("SELECT Lockout FROM Win32_UserAccount where Name = '"& @username &"'", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
       Local $Object_Flag = 0
       For $objItem In $colItems
           if @username = $objItem.Name Then
               Return $objItem.Lockout
           EndIf
       Next
    EndIf

EndFunc


func _NotificationPrompt($npState = true)

    Select
        Case $npState = true
            $Prompt = "You have been locked out of your Domain Account (computer logon)." & @CRLF _
                            & "Please contact the Helpdesk at extension 1234 to be unlocked."
            $WindowTitle = "LockedNotificationWindow"

            $hP = GUICreate('',0,0,0,0,0,$WS_EX_TOOLWINDOW)
            GLOBAL $hC = GUICreate($WindowTitle,305,105,@Desktopwidth-315,@DesktopHeight-1,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TRANSPARENT),$hP)
            ;GLOBAL $hC = GUICreate($WindowTitle,305,105,@Desktopwidth-315,@DesktopHeight-1,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TRANSPARENT),$hP)
                GUISetBkColor(0x3C3C3C)
            GUICtrlCreateLabel($NotificationTitle,8,8,290,100)
                GuiCtrlSetColor(-1,0xFFFFFF)
                GuiCtrlSetFont(-1,12,800,0,"Tahoma")
            GUICtrlCreateLabel($Prompt,8,32,290,100)
                GuiCtrlSetColor(-1,0xFFFFFF)
                GuiCtrlSetFont(-1,10,400,0,"Tahoma")

            GUISetState(@SW_SHOW)
            WinSetTrans($WindowTitle,"",135)
            WinActivate($WindowTitle)

            ;$aPos = WinGetPos($WindowTitle)
            WinMove($hC,'',@Desktopwidth-315,@DesktopHeight-155,305,105,2)

        Case $npState = false
            WinMove($hC,'',@Desktopwidth-315,@DesktopHeight,305,105,2)
            IF $hC <> "" Then GUIDelete($hC)
            IF $hP <> "" Then GUIDelete($hP)

    EndSelect

EndFunc

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...