• RSS
  • Twitter
  • FaceBook

Welcome to ISAserver.org

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

Program in C# using ISA 2004 SDK

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [ISA Server 2004 Misc.] >> ISA Server 2004 Programming >> Program in C# using ISA 2004 SDK Page: [1]
Login
Message << Older Topic   Newer Topic >>
Program in C# using ISA 2004 SDK - 4.Dec.2007 12:55:59 PM   
m_kk

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
Hello,

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.
Post #: 1
RE: Program in C# using ISA 2004 SDK - 5.Dec.2007 3:43:35 AM   
ferrix

 

Posts: 547
Joined: 16.Mar.2005
Status: offline
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.

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

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
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
-------------------------------------------------
static DWORD OnGetClientHeaders (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_PREPROC_HEADERS pHeaders)
{
CHAR url[URL_BUFFER_SIZE];

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.

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

 

Posts: 547
Joined: 16.Mar.2005
Status: offline
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.

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

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
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.

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

 

Posts: 547
Joined: 16.Mar.2005
Status: offline
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.

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

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
Oh yeah thanks dint get that. Thanks a lot for the help will try that.

(in reply to ferrix)
Post #: 7
RE: Program in C# using ISA 2004 SDK - 18.Dec.2007 10:20:25 AM   
m_kk

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
hii,

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.

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

 

Posts: 547
Joined: 16.Mar.2005
Status: offline
Use the WriteClient function to send an http response.  In your case a 302 redirect is probably appropriate.

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

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
hi,
thanks for the reply again. But WriteClient sends response to the client. I need to just redirect the client to a static URL.

(in reply to ferrix)
Post #: 10
RE: Program in C# using ISA 2004 SDK - 19.Dec.2007 3:22:23 PM   
m_kk

 

Posts: 25
Joined: 21.Nov.2007
Status: offline
Hi,

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.

< Message edited by m_kk -- 19.Dec.2007 3:38:01 PM >

(in reply to ferrix)
Post #: 11

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [ISA Server 2004 Misc.] >> ISA Server 2004 Programming >> Program in C# using ISA 2004 SDK Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts