×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

unlock user array

unlock user array

unlock user array

(OP)
Anyone know if this can be done, run vbscript popup a list of users locked out (an array)(create numbers next to the list) select the number of the user you want to unlock.

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

RE: unlock user array

>Anyone know if this can be done
Yes, probably. So what have you tried and where are you stuck?

RE: unlock user array

(OP)
So from the script below its easy enough to get them to echo out, but that's where my talent runs out to, I dont know much about how to get the information into a dynamic array, I have only ever done standard arrays e.g Dim sArray( 6, 1 ) and list the array, i know this is where I gather a dynamic array or dictionary should be used to list them. The Ubound statements really confuse me.

CODE -->

' FindLockedoutADUsers.vbs
' Sample VBScript to Find and List Locked Out Active Directory users.
' Author: http://www.morgantechspace.com/
' 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 

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

RE: unlock user array

(OP)
and i need it to pop up like this (off one of my scripts) easy if they static entries, but obviously the number will be next to a username and will execute a command to unlock the AD account.

CODE -->

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 

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close