hello.
I'm working on an ASP page that queries the Global Catalog of Active Directory for domain names and phone numbers.
For the most part, the script works and gets the result set. My problem comes in displaying the records in asp.
Here is the error message i get:
Response object error 'ASP 0106 : 80020005'
Type Mismatch
/phonebook/includes/test.asp, line 0
An unhandled data type was encountered
How do I fix this?
Here's the code:
<%
' If user enters "*", then filter on all people
' Else Search for all users whose surnames start with the last initial.
If letter_input = "*" Then
strName = "(sn=*)"
Else
strName = "(sn=" & letter_input & "*)"
End If
' Create ADO connection using the ADSI OLE DB provider
Set objADOConnection = CreateObject("ADODB.Connection")
objADOConnection.Open "Provider=ADsDSOObject;"
' Create ADO commmand object and associate it with the connection
Set objADOCommand = CreateObject("ADODB.Command")
objADOCommand.ActiveConnection = objADOConnection
' Create the command string using the four parts
objADOCommand.CommandText = "<GC://DC=DOMAIN_NAME,DC=com>;(&(objectCategory=person)" & strName &");sn,givenName;subtree"
' Set the number of records in the recordset logical page
objADOCommand.Properties("Page Size") = 20000
' Set the maximum result size
objADOCommand.Properties("Size Limit") = 20000
' Sort the results based on the cn attribute
objADOCommand.Properties("Sort On") = "cn"
' Execute the query for the user in the directory
Set objADORecordset = objADOCommand.Execute
If objADORecordset.EOF Then
Response.Write("No Records Found")
Else
Response.Write("<table border=1 cellpadding=0 cellspacing=0 align=left>")
While Not objADORecordset.EOF
Response.Write("<tr>")
' Display the row using the selected fields
Response.Write("<td>")
'strDisplayLine = objADORecordset.Fields("sn")
'Response.Write(strDisplayLine)
Response.Write(objADORecordset.AbsolutePosition)
Response.Write(",")
Response.Write(objADORecordset.RecordCount)
'strDisplayLine = objADORecordset.Fields("givenName")
'Response.Write(strDisplayLine)
Response.Write("</td>")
Response.Write("<td>")
strDisplayLine = objADORecordset.Fields("sn").value
Response.Write(strDisplayLine)
Response.Write(",")
strDisplayLine = objADORecordset.Fields("givenName")
Response.Write(strDisplayLine)
Response.Write("</td>")
Response.Write("</tr>")
' Advance to the next record
objADORecordset.MoveNext
Wend
Response.Write("</table>")
'Close Recordset and return memory
objADORecordset.Close
' Close the ADO connection
objADOConnection.Close
%>
Help please...
I'm working on an ASP page that queries the Global Catalog of Active Directory for domain names and phone numbers.
For the most part, the script works and gets the result set. My problem comes in displaying the records in asp.
Here is the error message i get:
Response object error 'ASP 0106 : 80020005'
Type Mismatch
/phonebook/includes/test.asp, line 0
An unhandled data type was encountered
How do I fix this?
Here's the code:
<%
' If user enters "*", then filter on all people
' Else Search for all users whose surnames start with the last initial.
If letter_input = "*" Then
strName = "(sn=*)"
Else
strName = "(sn=" & letter_input & "*)"
End If
' Create ADO connection using the ADSI OLE DB provider
Set objADOConnection = CreateObject("ADODB.Connection")
objADOConnection.Open "Provider=ADsDSOObject;"
' Create ADO commmand object and associate it with the connection
Set objADOCommand = CreateObject("ADODB.Command")
objADOCommand.ActiveConnection = objADOConnection
' Create the command string using the four parts
objADOCommand.CommandText = "<GC://DC=DOMAIN_NAME,DC=com>;(&(objectCategory=person)" & strName &");sn,givenName;subtree"
' Set the number of records in the recordset logical page
objADOCommand.Properties("Page Size") = 20000
' Set the maximum result size
objADOCommand.Properties("Size Limit") = 20000
' Sort the results based on the cn attribute
objADOCommand.Properties("Sort On") = "cn"
' Execute the query for the user in the directory
Set objADORecordset = objADOCommand.Execute
If objADORecordset.EOF Then
Response.Write("No Records Found")
Else
Response.Write("<table border=1 cellpadding=0 cellspacing=0 align=left>")
While Not objADORecordset.EOF
Response.Write("<tr>")
' Display the row using the selected fields
Response.Write("<td>")
'strDisplayLine = objADORecordset.Fields("sn")
'Response.Write(strDisplayLine)
Response.Write(objADORecordset.AbsolutePosition)
Response.Write(",")
Response.Write(objADORecordset.RecordCount)
'strDisplayLine = objADORecordset.Fields("givenName")
'Response.Write(strDisplayLine)
Response.Write("</td>")
Response.Write("<td>")
strDisplayLine = objADORecordset.Fields("sn").value
Response.Write(strDisplayLine)
Response.Write(",")
strDisplayLine = objADORecordset.Fields("givenName")
Response.Write(strDisplayLine)
Response.Write("</td>")
Response.Write("</tr>")
' Advance to the next record
objADORecordset.MoveNext
Wend
Response.Write("</table>")
'Close Recordset and return memory
objADORecordset.Close
' Close the ADO connection
objADOConnection.Close
%>
Help please...