'On Error Resume Next Set objExplorer = WScript.CreateObject("InternetExplorer.Application") objExplorer.Navigate "about:blank" objExplorer.ToolBar = 0 objExplorer.StatusBar = 0 objExplorer.Width=400 objExplorer.Height = 200 objExplorer.Left = 0 objExplorer.Top = 0 Do While (objExplorer.Busy) Wscript.Sleep 200 Loop objExplorer.Visible = 1 Dim adoCommand, adoConnection, strBase, strFilter, strAttributes Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN ' Setup ADO objects. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" adoCommand.ActiveConnection = adoConnection ' Search entire Active Directory domain. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strBase = "" Set objSystemInfo = CreateObject("ADSystemInfo") strDomain = objSystemInfo.DomainShortName ' Filter on user objects. strFilter = "(&(objectCategory=person)(objectClass=user))" ' Comma delimited list of attribute values to retrieve. strAttributes = "sAMAccountName,cn" ' Construct the LDAP syntax query. strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 100 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False ' Run the query. Set adoRecordset = adoCommand.Execute ' Enumerate the resulting recordset. Do Until adoRecordset.EOF ' Retrieve values and display. strUserName = adoRecordset.Fields("sAMAccountName").Value strCN = adoRecordset.Fields("cn").value set objUser = GetObject("WinNT://" & strDomain & "/" & strUsername) if objUser.IsAccountLocked = TRUE then objUser.IsAccountLocked = FALSE objUser.SetInfo objExplorer.Document.Body.InnerHTML = "Unlocking Account " & strUserName & " in Domain " & strDomain & "." Else objExplorer.Document.Body.InnerHTML = "Account " & strUserName & " in Domain " & strDomain & " was not locked." end if ' Move to the next record in the recordset. adoRecordset.MoveNext Loop ' Clean up. objExplorer.Document.Body.InnerHTML = "Job Completed" Wscript.Sleep 10000 objExplorer.Quit adoRecordset.Close adoConnection.Close