<%@ Language="VBScript" %> <% Option Explicit Response.Buffer = True Dim objConn, rs %> <% ' Lookup printer by IP address or FQDN and redirect to displayprinter.asp ' Used by Zabbix to link directly to printer details Dim ip, fqdn, lookupValue, cmd ip = Trim(Request.QueryString("ip") & "") fqdn = Trim(Request.QueryString("fqdn") & "") If ip <> "" Then lookupValue = ip ElseIf fqdn <> "" Then lookupValue = fqdn Else Response.Write "No IP or FQDN provided. Usage: printerlookup.asp?ip=x.x.x.x or printerlookup.asp?fqdn=hostname" Response.End End If Set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = objConn cmd.CommandText = "SELECT printerid FROM printers WHERE ipaddress = ? AND isactive = 1" cmd.Parameters.Append cmd.CreateParameter("@addr", 200, 1, 100, lookupValue) Set rs = cmd.Execute() If Not rs.EOF Then Response.Redirect "displayprinter.asp?printerid=" & rs("printerid") Else Response.Write "Printer not found: " & Server.HTMLEncode(lookupValue) End If rs.Close Set rs = Nothing Set cmd = Nothing objConn.Close %>