Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
' FindLockedoutADUsers.vbs
' Sample VBScript to Find and List Locked Out Active Directory users.
' Author: [URL unfurl="true"]http://www.morgantechspace.com/[/URL]
' Usage in CMD: C:\> CScript C:\Scripts\FindLockedoutADUsers.vbs
' -or- C:\>CScript C:\Scripts\FindLockedoutADUsers.vbs > C:\Scripts\LockoutUsers.txt
' ------------------------------------------------------'
Option Explicit
' Initialize required variables.
Dim adoCommand, adoConnection
Dim varBaseDN, varFilter, varAttributes
Dim objRootDSE, varDNSDomain, strQuery, adoRecordset
Dim lockoutFlag
Const Flag_LOCKOUT = 16
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
varDNSDomain = objRootDSE.Get("defaultNamingContext")
varBaseDN = "<LDAP://" & varDNSDomain & ">"
' varBaseDN is Domain DN, you can give your own OU DN instead of getting from "defaultNamingContext"
' like varBaseDN = "<LDAP://OU=TestOU,DC=Domain,DC=com>"
' Filter to list locked out user objects.
varFilter = "(&(objectCategory=person)(objectClass=user)(SAMAccountType=805306368)(LockoutTime>=1))"
' Comma delimited list of attribute values to retrieve.
varAttributes = "cn,samaccountname"
' Construct the LDAP syntax query.
strQuery = varBaseDN & ";" & varFilter & ";" & varAttributes & ",msDS-User-Account-Control-Computed;subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 1000
adoCommand.Properties("Timeout") = 20
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Ensure the user is still in locked out state by checking UF_LOCKOUT flag
' in the msDS-User-Account-Control-Computed attribute
lockoutFlag = adoRecordset.Fields("msDS-User-Account-Control-Computed").Value
If (lockoutFlag and Flag_LOCKOUT) Then
WScript.Echo adoRecordset.Fields("cn").Value & " " _
& adoRecordset.Fields("samaccountname").Value
End If
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop
' close ado connections.
adoRecordset.Close
adoConnection.Close
Dim WshShell:Set WshShell = WScript.CreateObject("WScript.Shell")
bullet = Chr(10) & " " & Chr(149) & " "
Do
response = InputBox("Please enter the script number you wish to run next:" & Chr(10) & bullet & "0.) Quit" & bullet &_
"1.) Rename Drives" & bullet & "2.) MoveTo CopyTo" & bullet & "3.) Registry Entries" & bullet & "4.) CreateFolders" &_
bullet & "5.) Wallpaper" & bullet & "6.) Description in AD" & bullet & "7.) Install All Registry Files" & bullet & _
"8.) Signature" & Chr(10), "Run Script", "Select a script to Run")
If response = "" Then
MsgBox "Enter a Value between 1 and 8, OR 0 to Quit"
else if response = "0" then WScript.Quit 'Detect Cancel
If IsNumeric(response) Then Exit Do 'Detect value response.
MsgBox "You must enter a numeric value.", 48, "Invalid Entry"
end if
Loop