Program in C# using ISA 2004 SDK (Full Version)

All Forums >> [ISA Server 2004 Misc.] >> ISA Server 2004 Programming


m_kk -> Program in C# using ISA 2004 SDK (4.Dec.2007 12:55:59 PM)


I am developing a Web filter plugin for ISA 2004 server. I have to program the DLL in c#. I was wondering if it is possible to use the 2004 SDK (event notifications)for C# programs since the examples mentioned in the SDK are all in vc++.

Thank you.

ferrix -> RE: Program in C# using ISA 2004 SDK (5.Dec.2007 3:43:35 AM)

Oh danger.  I love .NET and am a veteran filter coder, but IMO the two things really ought not to be mixed.

MS does not support ISA filter work in .NET, and I would not be surprised to learn that there could be fundamental incompatibilities underlying that fact.

If you simply MUST use c#, you'll need to write a bridge DLL in unmanaged c++ to marshal between the WPF interface and your main processing code.  There are no ".NET hooks" so you have to make essentially an adaptor.

Not to presume anything about your coding either, but just to anyone who reads this... You need to be _good_ at c++ in order to do filters.  This is because the filters run in-process with the firewall.  Any memery management slip-up or other fumble, and you bring down the whole service. 

As a parting shot, I'm not sure what issues may be introduced when you cause the firewall process to spin up the .NET runtime.  Surely a memory hit, but I'm thinking about thread management and other subtler resource gothcas.

m_kk -> RE: Program in C# using ISA 2004 SDK (11.Dec.2007 5:55:38 PM)

Thanks for the information. It saved a lot of time. I now have a filter developed in vc++. But got a problem when ISA server is configured as a transparent proxy. The hostname header is missing. my current code is as follows

DWORD dwSize;

// url
dwSize = sizeof(url);
memset(url, '\0', dwSize);
pHeaders->GetHeader(pfc, TEXT("url"), url, &dwSize);

if ( *url == '\0' ) {
strcpy_s(url, "-");



When ISA is a transparent proxy I only get the path in the URL but not the hostname. It works fine in no-transparent mode. If you can guide me to a solution it would be great.

Thank you.

ferrix -> RE: Program in C# using ISA 2004 SDK (11.Dec.2007 5:57:54 PM)

Why should there be a host name?  If you wireshark the traffic you'll see that the values the API returns are correct.  Look at getting the Host header in these cases.

m_kk -> RE: Program in C# using ISA 2004 SDK (11.Dec.2007 6:06:15 PM)

The filter plugin gets the requested URL from the ISA server and forwards the hostname to our own policy server for decision making in order to restrict for example porn sites.

It works fine for the non-transparent since I ve found the header information includes the complete URL. But for transparent mode the header seems to be split into 2 lines. I am not sure of this though.

I was wondering if I could get the hostname somehow when it is in transparent mode.

Thanks again.

ferrix -> RE: Program in C# using ISA 2004 SDK (11.Dec.2007 6:10:22 PM)

Read closer above.  You need to get the "Host" header, it will contain the data that is "missing" from the url.  Per RFC, the url includes protocol and host info when it's a proxy connection.  Normal intercepted HTTP requests are not in this format.

m_kk -> RE: Program in C# using ISA 2004 SDK (11.Dec.2007 6:13:56 PM)

Oh yeah thanks dint get that. Thanks a lot for the help will try that.

m_kk -> RE: Program in C# using ISA 2004 SDK (18.Dec.2007 10:20:25 AM)


Your solution worked great last time. I have one question, My web filter looks at user's requests and it detects faulty Web pages by looking into host name (which is already done) and redirects the user to a particular URL . Is there any source or simple code snippet that describes how to redirect a user to a particular URL using ISAPI?. I looked through internet but they seem complicated since I am new to ISAPI and filter development.

ferrix -> RE: Program in C# using ISA 2004 SDK (18.Dec.2007 10:36:50 AM)

Use the WriteClient function to send an http response.  In your case a 302 redirect is probably appropriate.

m_kk -> RE: Program in C# using ISA 2004 SDK (18.Dec.2007 11:32:34 AM)

thanks for the reply again. But WriteClient sends response to the client. I need to just redirect the client to a static URL.

m_kk -> RE: Program in C# using ISA 2004 SDK (19.Dec.2007 3:22:23 PM)


Thanks for the solution again. I have one more question. When the ISA 2004 server passes the user requested url to the web filter plugin. Does the url include the users's security or primary group information?

Thanks in advance.

Page: [1]