Board index » Visual Studio » Inscrutable Type Mismatch Error
|
hageman
|
Inscrutable Type Mismatch Error
Visual Studio224
I've taken Charles Oppermann's excellent phone directory command line VBS and tried to use it as a web application. I have added the necessary input field and output location but the very end of the script throws Microsoft VBScript runtime error '800a000d' Type mismatch errors. My entire site utilizes user authentication so I know that the problem can't be there but I'm missing something else, perhaps in my variable declaration. The specific line causing the error is in the final loop: strDisplayLine = objADORecordset.Fields("cn").Value & vbTab = = = = = = = = = = <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>LDAP Lookup</title> <style type="text/css"> body, input, select, table, textarea { font-size: 9pt; font-family: arial; } .niceButton { font-size : 9pt; font-family : arial; background-color : #eaeaea; color : #333333; font-weight : bold; border-width : thin; } </style> <% dim strPerson, objADsRootDSE, strADsPath, strBase, strObjects, strName, strAttributes, strScope, objADOConnection, objADOCommand, objADORecordset, strDisplayLine, strFilter strPerson = trim(request.form("last")) ' Input box is not empty and Cancel button was not clicked ' Build the query string ' Active Directory OLEDB Provider format has four parts separated by semi-colons: ' Root: which is the starting point for the search ' Filter: conditions to search on, using RFC 2254 format ' Attributes: attributes to return ' Scope: base, onelevel or subtree for entire directory partition ' Specify the search base. ' We'll use the global catalog for performance reasons since the ' Name and Telephone number attributes are available from the GC ' First, need to discover the local global catalog server Set objADsRootDSE = GetObject("GC://RootDSE") ' Form an ADsPath string to the DN of the root of the Active Directory forest strADsPath = "GC://" & objADsRootDSE.Get("rootDomainNamingContext") ' Wrap the ADsPath with angle brackets to form the base string strBase = "<" & strADsPath & ">" ' Release the ADSI object, no longer needed Set objADsRootDSE = Nothing ' Specify the LDAP filter ' First, indicate the category of objects to be searched (all people, not just users) strObjects = "(objectCategory=person)" ' If user enters "*", then filter on all people If (strPerson = "*") Then strName = "(sn=*)" Else strName = "(sn=" & strPerson & "*)" End If ' Add the two filters together strFilter = "(&" & strObjects & strName & ")" ' Set the attributes we want the recordset to contain ' We're interested in the common name and telephone number strAttributes = "cn,telephoneNumber" ' Specify the scope (base, onelevel, subtree) strScope = "subtree" ' 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 = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope ' Set the number of records in the recordset logical page 'objADOCommand.Properties("Page Size") = 20 ' Set the maximum result size objADOCommand.Properties("Size Limit") = 20 ' 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 strDisplayLine = "No records were found." Else ' Loop through all the returned records While Not objADORecordset.EOF ' Display the row using the selected fields strDisplayLine = objADORecordset.Fields("cn").Value & vbTab ' Check to see if telephone number field is null If IsNull(objADORecordset.Fields("telephoneNumber")) Then strDisplayLine = strDisplayLine & "(number not listed)" Else ' Retrieve telephone number and add to line strDisplayLine = strDisplayLine & objADORecordset.Fields("telephoneNumber") End If ' Advance to the next record objADORecordset.MoveNext Wend End If ' Close the ADO connection objADOConnection.Close %> </head> <body text="#333333"><%=strDisplayLine%></body></html> - |
