Hello,
This time I brought code. :) I'm trying to read an excel spreadsheet
and see if there are any users in that spreadsheet that are disabled
in AD, and if so, i need it to be flagged in column B as such:
I can get the the script to return a value if I leave out the
useraccountcontrol part (but all that is doing is seeing of the
account exists.) I'd like to be able to see if the account exists and
it is disabled, flag it as suchIf anyone could provide some help,
I'd really appreciate it. I've been working on this for 4 hours
today. :(
Thanks in advance
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\info
\CurrentCustodians.xls")
objExcel.Visible = True
i = 1
Do Until objExcel.Cells(i, 1).Value = ""
strName = objExcel.Cells(i,1)
objCommand.CommandText = _
"SELECT * FROM 'LDAP://dc=ughome,dc=com' WHERE objectCategory='user'
" & _
"AND samAccountName='" & strName & "'AND
UserAccountControl:1.2.840.113556.1.4.803:=2"
Set objRecordSet = objCommand.Execute
If objRecordset.RecordCount = 1 Then
objExcel.Cells(i,2) = "User is Disabled"
Else
objExcel.Cells(i,2) = "User is Active"
End If
i = i + 1
objRecordset.Close
Loop
objConnection.Close
Replies