billybarty
Technical User
How can I get a list of disabled accounts from AD Domain Users group?
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.
Dim fso, f
Dim conn
Dim rs
Dim provider
Dim strSql
Set conn = CreateObject("ADODB.Connection")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile("C:\Temp\Enabled.txt")
provider = "ADsDSOObject"
With conn
.Provider = provider
.Open "Active Directory Provider"
End With
strSql = "SELECT sn, givenname, adspath, useraccountcontrol FROM 'LDAP://DC=[b]YOUR DOMAIN[/b],DC=com' WHERE objectclass = 'user' AND useraccountcontrol = 514 ORDER BY sn"
set rs = conn.execute(strSql)
Do until rs.EOF
f.WriteLine rs("sn") & ", " & rs("givenname") & " - " & rs("useraccountcontrol") & " - " & rs("adspath")
rs.MoveNext
Loop
f.Close
msgbox "Done"
Set conn = Nothing
Set rs = Nothing
Set fso = Nothing