ActiveX dll not working on IIS 8.5 - iis

ActiveX dll not working on IIS 8.5
We have a classic ASP application that uses and ActiveX dll to generate an image on the fly. It was working find on Window 2003 with IIS6. But we're migrating it to Windows 2012 and IIS 8.5. The DLL is registered on the server, configured to run under it's own app pool (No Managed Code, Classic pipeline mode). It's virtual directory is configured to run as an application and has a handler mapping for *.dll to point to the DLL for all verbs with Execute Access rights, which is the same config for IIS6.
The ASP code to render the HTML calling DLL looks like this:
<%dim SpokeData
dim JobName
dim NumOfExperts
dim ThisDirNo
dim ThisSel
dim PAPIType
dim JobType
dim SpokeDataShort
SpokeData = trim(Request.QueryString("Data"))
JobName = trim(Request.QueryString("JobName"))
NumOfExperts = trim(Request.QueryString("Exp"))
PAPIType = trim(Request.QueryString("PAPIType"))
JobType = trim(Request.QueryString("JobType"))
CalcDate = trim(Request.QueryString("Date"))
For ScaleNo = 1 to 20
ThisSel = Mid(SpokeData,(ScaleNo*2),1)
ThisDirNo = Mid(SpokeData,(ScaleNo*2)-1,1)
If ThisSel = "1" then SpokeDataShort = SpokeDataShort & ThisDirNo else SpokeDataShort = SpokeDataShort & "0"
Next
Response.Write("<div id='Wheel'><img style='margin-left:20px' src='http://www.example.com/jpwheel/jpwheel.dll?Handler=Render&nori=" & PAPIType & "&dir=" & SpokeDataShort & "&" & Now & "'></div>")
%>
The HTML then lookslike this: <img src="http://www.example.com/jpwheel/jpwheel.dll?Handler=Render&nori=N&dir=55555050555000000000&11/05/2015 16:05:24" style="margin-left:20px"> if I try to download this directly I get a 500 error (no error log unfortunately).
It is working on IIS6, not working on IIS8.5. Can anyone cast some light on migrating ActiveX server-side DLLs to IIS8.5? One thing I haven't done is check the dependencies for the DLL, can anybody recommend a tool for that? I'm guessing with windows 2003 coming to end of life a number of people are running into issues like this.

The problem was caused by using the incorrect handler mapping. I had it setup as a Script Map. It needed to be a Module Mapping with the following details:
Request path: *.dll
Executable: Path to the jpwheel.dll
Module: IsapiModule
Name: jpwheel
Request Restrictions: All Verbs, Access required: Script
Feature Permissions: Read, Script, Execute
So it's working now.

Related

Force a COM server to remain open

I have a COM automation server hosted by a VB6 exe.
The COM API is used from Excel VBA:
Dim o as MyCOMAPI.MyCOMType
Set o = new MyCOMAPI.MyCOMType
o.DoSomething
When I create objects in VBA the exe is started along with COM automation and VBA can use the API.
But the exe is closed quickly and "randomly" by Excel, I guess when Excel decides it doesn't need the COM API anymore.
This behaviour is causing random errors.
The simple solution is to start the exe before running the VBA code ; in this case all is working fine as the exe won't stop running until closed by the user.
Have you some information/documentation about the way Excel VBA manages calls to hosted APIs?
Is there a way to avoid this behaviour and have the exe kept open until the VBA code decides to stop it?
This would be the default behavior for a COM automation server when the last object is dereferenced, meaning that the variable that points to the server is set to nothing.
Now, if your code looks something like this today:
Sub MyFunction()
...
Dim o as MyCOMAPI.MyCOMType
Set o = new MyCOMAPI.MyCOMType
o.DoSomething
End Sub
Then, the server life is connected to the life of the o variable. That variable gets set to nothing when the function is finished, and then the server will be shut down (unless there are other variables keeping it alive).
To make sure that your COM server is kept alive for a longer time, simply define the variable as a Public variable as in the sample below.
This sample will start and show Excel and keep it open until the ShutdownExcel function is called.
Public o As Excel.Application
Sub MakeSureExcelIsRunning()
If o Is Nothing Then
Set o = New Excel.Application
o.Visible = True
End If
End Sub
Sub ShutdownExcel()
Set o = Nothing
End Sub
From COM docs.
**Component Automation**
Shutting Down Objects
ActiveX objects must shut down in the following way:
If the object's application is visible, the object should shut down only in response to an explicit user command (for example, clicking Exit on the File menu) or the equivalent command from an ActiveX client.
If the object's application is not visible, the object should shut down only when the last external reference is gone.
If the object's application is visible and is controlled by an ActiveX client, it should become invisible when the user shuts it down (for example, clicking Exit on the File menu). This behavior allows the controller to continue to control the object. The controller should shut down only when the last external reference to the object has disappeared.
© Microsoft Corporation. All rights reserved.
When you write an COM server exe the first thing you do it take a reference to yourself when starting as a normal exe else the exe shuts down as soon as initialisation is over.

write in event log in vb.net

I've developped a sharepoint 2007 feature in vb.net.
Inside, have an application page and in onload method, i want to write message in event log
Dim cs As String = "TESTLOG"
Dim elog As New EventLog()
Dim sourceExist As Boolean
Try
sourceExist = EventLog.SourceExists(cs)
Catch ex As Exception
sourceExist = False
End Try
If Not sourceExist Then
Dim ev As New EventLogPermission(EventLogPermissionAccess.Administer, ".")
ev.PermitOnly()
EventLog.CreateEventSource(cs, "TESTLOG")
End If
elog.Source = cs
elog.EnableRaisingEvents = True
EventLog.WriteEntry(cs, message, EventLogEntryType.[Error])
The source is correctly created but when i try to write, i've an access denied.
I go to registry to set permission full control at everyone but still have the message.
HKEY_LOCAL_MACHINE
SYSTEM
CurrentControlSet
Services
Eventlog
Application
How can i write message in event log?
Thanks
I think you need to make sure the user account that is running the website has full access to the event log. See if the following link is of any help.
KB2028427

Calling COM Methods using Microsoft Detours

I am trying to hook compile method of the jscript.dll located in C:\Windows\System32 which is the core of Internet Explorer Javascript Engine.
The code work fine for API Calls for example RegOpenKeyExW which is reponsible to read registery values.
But when I try to use COleScript::Compile in jscript.dll it get me an error.
this is my Code:
FunctionHook* CompileFunExWHook = new FunctionHook();
CompileFunExWHook->Identifier = "COleScript::Compile";
CompileFunExWHook->Module = "jscript.dll";
CompileFunExWHook->Detour = (PBYTE)MyRegOpenKeyExW;
HookManager::Instance()->CreateHook(CompileFunExWHook);
pOriginalRegOpenKeyExW = (pRegOpenKeyExW)(HookManager::Instance()- >GetHook("COleScript::Compile")->DetourAddress);

Classic ASP - Request object Is Empty

I'm working on adding a feature to an old classic asp site and ran into an interesting problem. The following line on the page results in the helpful error "Object required:'' "
strServerName = Request.ServerVariables("server_name")
When I attached a debugger to look at it, Request is in fact Empty, which I don't understand how that can happen? This line exists on several pages and executes with no problems besides this one. In this case, the page is executed by a Redirect from another page.
I've been searching for a solution for a day or so now and haven't been able to locate anything that's been helpful. I'm desperate, any ideas would be greatly appreciated.
Oh, and if any more information is required, please don't hesitate to call me out.
Thanks!
Update 1
As requested, below is the entire code snippet wrapped in <% %> tags. This block exists as first code within the file (named 'order-results-instant.asp'):
<%
strServerName = Request.ServerVariables("server_name")
strServerName = UCase(strServerName)
strServerURL = "http://localhost/cbr"
strServerURLhttps = "https://localhost/cbr"
strConnect = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=CBR; Integrated Security=SSPI"
Dim objConn
Dim sql_stmt
Dim rs
%>
Update 2
I've used the following 2 methods to redirect execution to this page - perhaps this can cause the request to be lost?
'Response.Redirect strServerURL & "/order-results-instant.asp?gwstep=1"
Response.Write "<META HTTP-EQUIV=""refresh"" content=""5;URL=" & strServerURL & "/order-results-instant.asp?gwstep=1"">"
Scan through the rest of the code. At the Global level you will find this:-
Dim Request
Rename this variable and its current usage and the Request object attached to the script context will become visible.
On your server is the Active Server Pages Web Service extension allowed (turned on) ?
I copied your code into my test asp file with the following code and it redirected just fine.
<%
strServerName = Request.ServerVariables("server_name")
strServerName = UCase(strServerName)
strServerURL = "http://localhost/"
strServerURLhttps = "https://localhost/"
strConnect = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=CBR; Integrated Security=SSPI"
Dim objConn
Dim sql_stmt
Dim rs
Response.Write(strServerName)
if Request.Querystring("test") <> "1" then
Response.Redirect("http://" + strServerName + "/asptest.asp?test=1")
end if
%>
The only real difference is I am adding "http://" to the redirect. Maybe something I did will shed some light to help you solve your issue.
thanks
Does it work if you try to access it at an earlier point in the page?

Classic ASP/IIS6: How to search the server’s mime map?

This is the same question as this but I'm looking for a classic ASP solution.
I have a third party control to provide secure downloads but it expects you to provide the response.contenttype value. I'm trying to have the browser prompt with the following:
Response.AddHeader "Content-Disposition", "attachment;filename=""" & strFileName & """"
However Safari doesn't like any of the suggested content types (does odd things with the file name - like add ".exe" to the end).
application/x-msdownload
application/force-download
So I'd either like to query IIS for the correct content type or find a generic content type that would let the browser figure it out in a somewhat reliable fashion.
Typically the mimemap being used by the site is stored at server level and you can get into permission issues trying to read it. It requires some nasty ADSI code.
Have you tried the standard application/octet-stream as a mime type?
From Reading the server mimemap:
Public Function GetMimeType(ByVal Extension)
Dim oMimeMap
Dim vntMimeType
Dim avntMap()
Set oMimeMap = GetObject("IIS://LocalHost/MimeMap")
If Left(Extension, 1) <> "." Then Extension = "." & Extension
avntMap() = oMimeMap.MimeMap
For Each vntMimeType In avntMap
If vntMimeType.Extension = Extension Then
GetMimeType = vntMimeType.MimeType
Exit For
End If
Next
If GetMimeType = "" Then GetMimeType = "application/octet-stream"
End Function
Note: the code calling GetObject is required to be an Operator in WWW Service Master properties.

Resources