Jump to content

LockoutStatus - Tutorial


Country73
 Share

Recommended Posts

I've been working on a small tutorial to show how to use the LockoutStatus.exe

( http://www.microsoft.com/download/en/details.aspx?id=15201 )

We've had a steady turn around on contractors at my job, so my boss has asked if I could throw together a list of programs to demonstrate how to use some of the key tools we use on a regular basis.

Everything seemed to be running smoothly until I attempted to automate the steps to show how to use the LockoutStatus program. Yes the tool comes with a walk-through on how to use it, but my boss wants to visually show how it's done, just like the others I've already had to throw together, so everything is uniform...

If you're not familiar with the LockoutStatus tool, it is used to view/unlock domain accounts across the Domain Controllers.

I've got as far as launching the LockoutStatus, using the individuals ID to do the query, and returning results on whether the account is "Locked" or "Not Locked" across our network.

I've ran through all of the "ControlListView" and "_GuiCtrlListView_..." commands, but I can't find a way to select a specific item (Locked) in the ListView and then select "Unlock Account"

This script will run through what I've got so far, you'll just need the LockoutStatus.exe located in your Temp Directory for it to launch.

Global  $DOMAIN = "" ;Your Domain here
Global  $TOOL   = @TempDir & "\LockoutStatus.exe"
Global  $CMD    = "-u:" & $DOMAIN & "\" & @UserName

If Not FileExists( $TOOL ) Then
    ConsoleWrite( "Unable to locate: " & $TOOL & @CRLF )
    Exit
EndIf

If ProcessExists("LockoutStatus.exe") Then
    ConsoleWrite( "Tool is already running, please close." & @CRLF )
    Exit
EndIf

ShellExecute( $TOOL, $CMD, @TempDir, 'open', @SW_SHOW )
Do
Until WinExists( "Collecting Data", "Please wait while data is collected..." )
Do
Until Not WinExists( "Collecting Data", "Please wait while data is collected..." )
WinActivate(@UserName,"")


Local $iCount, $NotLock_Count = 0, $Lock_Count = 0, $i

$iCount = ControlListView(@UserName,"","SysListView321","GetItemCount")
For $i = 0 To $iCount
    Local $gText = ControlListView(@UserName,"","SysListView321","GetText",$i,2)
    If StringLen($gText) > 6 Then $NotLock_Count += 1
    If StringLen($gText) = 6 Then $Lock_Count += 1
Next
ConsoleWrite("Locked on: " & $Lock_Count & @CRLF & "Not Locked on: " & $NotLock_Count & @CRLF)

I know you can script a means to just hit each DC and simply unlock, but we are required to use this tool to handle those unlocks.

Once/If I get this portion straightened out I can start filling in all of the prompts and how to select a specific ID to search against.

Any pointers/suggestions/solutions would be appreciated.

Thanks,

Edit:

Forgot, you will also need to supply your domain name in the $DOMAIN variable...

Edited by Country73

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

How are you going about unlocking the account from this tool? Where is it failing? In other words, what is it that you're attempting to do that isn't doing what you expect?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Through the manual process:

1. Search all entries for a "Locked" item

2. Highlight that item and right click on it.

3. Submenu now appears where you select the "Unlock Account"

4. Msgbox returns success or failed.

So I'm looking to find how to select the item and then select the "Unlock Account" from the submenu.

I've attached a small snapshot of what I'm viewing.

~ DC Name and Site have been blocked out

~ "User State" would show "Locked" for item I want to select, example only shows "Not Locked"

If it were to show "Locked", I want to be able to select that item and then simulate a right click on that item to get the submenu to appear. (Unable to get snap-shot of submenu, but first item that is listed is "Unlock Account")

I hope that helps.

LockOut.bmp

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

@wraithdu

Since my original post, I have tried the following:

Example:

Local $hwd = ControlGetHandle( @UserName, "", "SysListView321" )
_GUICtrlListView_SetItemSelected( $hwd, 1, True, True )
_GUICtrlListView_EnsureVisible( $hwd, 1 )
ConsoleWrite( _GUICtrlListView_GetItemText( $hwd, 1, 2 ) & @CRLF)

This will "select" the second row and gather the text from the "User State" ( Locked / Not Locked ), but I'm drawing a blank as to how to simulate the right-click for the submenu...

*That section of code would go into my - For...Next - to only select items that show "Locked"

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

For selecting and right clicking an item in the Listview try using _GUICtrlListView_ClickItem or ControlClick using the Right mouse button.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hmm, getting me a little closer.

Could have sworn I looked at that command earlier, but might have had more code directly afterwards that closed out the "submenu" before I could make a selection...

Just found the code that initially made this selection, but I had some trailing code that closed out the submenu before making any selection... Guess that's what I get for jumping ahead of myself.

Ok, I'm going to run with this a bit and see if I can figure out the selecting of "Unlock Account" and answering the Msgbox success/failed response.

Thanks for the assistance BrewManNH

Edit:

(It was the _GUICtrlListView_ClickItem()... )

Edited by Country73

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

  • 3 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...