I'm trying to write an ASP page that will return a list of Active Directory User accounts that are disabled. I've written several ASP pages and am reasonably comfortable with that, but I've yet to use LDAP in the query. Below is the script I've started to put together. Part of it is from Microsoft TechNet and part is from a thread on this forum. Unfortunately, it doesn't work and returns the following error:
Provider error '80040e14'
One or more errors occurred during processing of command.
The message refers to line 13 which is the command.execute line. I figure this means my command.text line is out of whack, but I don't know enough about the syntax to figure it out.
I'd appreciate any help I can get.
<%@language=vbscript%>
<%
Const ADS_UF_ACCOUNTDISABLE = 2
Set objConnection = CreateObject("ADODB.Connection"
objConnection.Provider="ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "select distinguishedName, userAccountControl from 'LDAP://DC=FISD, DC=org' where objectCategory=User"
Set objRecordset = Server.CreateObject("ADODB.Recordset"
Set objRecordSet = objCommand.Execute
intCounter = 0
While Not objRecordset.EOF
intUAC=objRecordset.Fields("userAccountControl"
If intUAC And ADS_UF_ACCOUNTDISABLE Then
response.write objRecordset.Fields("distinguishedName" & " is disabled."
intCounter = intCounter + 1
End If
objRecordset.MoveNext
Wend
response.write "A total of " & intCounter & " accounts are disabled."
objConnection.Close
%>
Provider error '80040e14'
One or more errors occurred during processing of command.
The message refers to line 13 which is the command.execute line. I figure this means my command.text line is out of whack, but I don't know enough about the syntax to figure it out.
I'd appreciate any help I can get.
<%@language=vbscript%>
<%
Const ADS_UF_ACCOUNTDISABLE = 2
Set objConnection = CreateObject("ADODB.Connection"
objConnection.Provider="ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "select distinguishedName, userAccountControl from 'LDAP://DC=FISD, DC=org' where objectCategory=User"
Set objRecordset = Server.CreateObject("ADODB.Recordset"
Set objRecordSet = objCommand.Execute
intCounter = 0
While Not objRecordset.EOF
intUAC=objRecordset.Fields("userAccountControl"
If intUAC And ADS_UF_ACCOUNTDISABLE Then
response.write objRecordset.Fields("distinguishedName" & " is disabled."
intCounter = intCounter + 1
End If
objRecordset.MoveNext
Wend
response.write "A total of " & intCounter & " accounts are disabled."
objConnection.Close
%>