Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

communication between isapi extension dll and other applications

3 views
Skip to first unread message

behzad

unread,
Aug 26, 2003, 7:38:24 AM8/26/03
to
hi,
How can an isapi extension dll communicate with an application running on
usual desktop ?

thanks,
Behzad


William DePalo [MVP VC++ ]

unread,
Aug 26, 2003, 10:51:05 AM8/26/03
to
"behzad" <behz...@yahoo.com> wrote in message
news:uYxrMa8...@tk2msftngp13.phx.gbl...

> How can an isapi extension dll communicate with an application running on
> usual desktop ?

ISAPI DLLs extend Microsoft's web server, IIS. Web servers don't deal in
desktops. They deal in pages which they return to clients. Those clients may
be running on Windows desktops or Apples' or KDE's etc.

Can't the desktops that you care about send a GET or POST referencing the
ISAPI extension in the URL.

Regards,
Will


behzad

unread,
Aug 26, 2003, 11:52:18 PM8/26/03
to
hi,
thanks for your reply,
I have an application running on a PC. It should be run 24 hours, I want to
control it via web pages. So I need a mechanism to link the web pages to my
application. How this can be done ? I tryed pipes, casyncsocket, but none of
them answered. How this can be done ?

thanks ,
Behzad
_____________________________________________________________


"behzad" <behz...@yahoo.com> wrote in message
news:uYxrMa8...@tk2msftngp13.phx.gbl...

William DePalo [MVP VC++ ]

unread,
Aug 27, 2003, 12:26:41 AM8/27/03
to
"behzad" <behz...@yahoo.com> wrote in message
news:OUWKX6Eb...@tk2msftngp13.phx.gbl...

> I have an application running on a PC. It should be run 24 hours, I want
to
> control it via web pages. So I need a mechanism to link the web pages to
my
> application. How this can be done ? I tryed pipes, casyncsocket, but none
of
> them answered. How this can be done ?

Ah, I see. When I read your question the first time I thought you wanted to
have the web server communicate with the desktop running the browser. In the
general case, where server and browser are at arbitrary locations on the
network, that would have been problematic.

So then, your application is a server that can field requests from client
browsers? If so, an option is to build a scaled-down version of a web
server. You might want to start with this sample which uses MFC to build a
server which binds a socket to a port (most often 80) waiting for an HTTP
request.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_httpsvr.asp

If that PC already runs a web server, another option is to use ISAPI, ASP or
CGI etc either to implement the application, or to implement a bridge to, or
an adaptor for, your application. That is, the user might browse to

http://YourServer/YourISAPIDll.dll?request=doSomething

The ISAPI DLL (or ASP page or CGI app) looks at the URL to determine the
request type and then makes the corresponding request via RPC to your
application. The application returns its result to your web application in
the usual way. Then the web application builds an HTML formatted "page"
containing the response which the browser displays to the user.

I don't know if you have jumped on the .Net bandwagon yet, but one of the
reasons it exists is to put in place the infrastructure that allows
applications to be viewed as "Web services" to be "consumed" by remote
clients possibly running browsers.

Regards,
Will


behzad

unread,
Aug 27, 2003, 12:42:37 AM8/27/03
to
Again thanks,
I have written both cgi and isapi dll.
My question is exactly this:
how a cgi or isapi dll can communicate with an application which is
previously running, I mean both the application and the web server are on
the same machine.
I tryed to use a pipe on isapi dll , but it could connect to other
applications running on server. I tryed to send messages, too.
I think there is something That I do not know!
I appreciate if u give me some hints about how this connection can be
established.
U wrote about RPC, if it is the answer , do u know any tutorials about it ?

thanks
behzad

"William DePalo [MVP VC++ ]" <willd....@mvps.org> wrote in message
news:#7hJpNFb...@TK2MSFTNGP10.phx.gbl...

William DePalo [MVP VC++ ]

unread,
Aug 27, 2003, 4:02:17 PM8/27/03
to
"behzad" <behz...@yahoo.com> wrote in message
news:Opx3eWFb...@TK2MSFTNGP12.phx.gbl...
> Again thanks,

You are welcome.

> how a cgi or isapi dll can communicate with an application which is
> previously running, I mean both the application and the web server are on
> the same machine.

At the risk of staring the obvious, the application has to expose some
interface to outsiders. :-) You can use sockets, named pipes, remote
procedure calls, mail slots, COM, shared memory, shared files, ... etc

> I tryed to use a pipe on isapi dll , but it could connect to other
> applications running on server. I tryed to send messages, too.
> I think there is something That I do not know!

A pipe is a securable object on NT. By _default_ objects are accessible to
threads which run in the same user context as the thread which created the
object. Depending on the security model you choose for the extension it may
run as LocalSystem or IUSR_machineName. If your application rns under a
different account, that may be way you have trouble. But you shouldn't have
to guess. Virtuallu all of theWin32 functions that can fail do so by setting
the last error for the thread which you can retrieve with GetLastError().
The possible return values are enumerated in <winerror.h>

If access control is the problem, you can put a security descriptor on the
pipe that allows any thread running as an authenticated user to gain access
with these few lines:

// Warning, this was cut and pasted, so it may not compile

BYTE SD[SECURITY_DESCRIPTOR_MIN_LENGTH];
SECURITY_ATTRIBUTES sa;

sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = &sd;

InitializeSecurityDescriptor( (PSECURITY_DESCRIPTOR) &sd,
SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl( (PSECURITY_DESCRIPTOR) &sd, TRUE, (PACL) NULL,
FALSE);

hPipe = CreateNamedPipe("name",
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
YourOutputSize, YourInputSize,
YourTimeoutPeriod, &sa);

> U wrote about RPC, if it is the answer , do u know any tutorials about it
?

The nice thing about RPC, is that client and server communicate via simple
function call once you have the defined the interface and have created the
proxies and stubs. It does take a little while to get up to speed, though.
You should find a link to a tutorial on this page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/overviews.asp

Regards,
Will


behzad

unread,
Aug 30, 2003, 4:08:38 AM8/30/03
to
hi,
thanks for your reply,
Finally I could have all componenets working. It was possibly security
problem. That piece of code did not work, but I changed the anonymous user
account which IIS uses to an admin account , and it worked ok! Maybe it is
not ok for an isapi dll communuicae with an application in a usual manner in
Microsoft point of view.

again thanks,
Behzad


"William DePalo [MVP VC++ ]" <willd....@mvps.org> wrote in message

news:O#9AwYNbD...@TK2MSFTNGP12.phx.gbl...

William DePalo [MVP VC++ ]

unread,
Aug 30, 2003, 10:44:47 AM8/30/03
to
"behzad" <behz...@yahoo.com> wrote in message
news:uUGKs3sb...@TK2MSFTNGP09.phx.gbl...
> thanks for your reply,

You are welcome.

> Finally I could have all componenets working. It was possibly security
> problem.

Where services are concerened, it usually is.

> That piece of code did not work,

I'm sorry it didn't work in your situtation. I cut and pasted the code into
the post from a _running_ ISAPI application of mine that uses an extension
to receive requests ultimately bound for a NT service with a named pipe
interface.

> but I changed the anonymous user
> account which IIS uses to an admin account , and it worked ok!

I'm glad you resolved the problem.

> Maybe it is not ok for an isapi dll communuicae with
> an application in a usual manner in Microsoft point of view.

That's not correct. An ISAPI extension is just a DLL that is hosted by a
particular NT service. The usual rules apply.

Regards,
Will


behzad

unread,
Aug 30, 2003, 12:15:13 PM8/30/03
to
hi,
It was your hint that I started to play a little with IIS management. thanks
a lot for that ;)
maybe the differenece in your code and mine is that u wanted to link your
isapi to an NT service, but I wanted to link it to an a usual application.
In your case, both were in services address and in my situation the isapi is
in services space and my application is the adrress space of the user that
logged on. Of course this is just a guess.

again thanks for your hint,
Behzad

"William DePalo [MVP VC++ ]" <willd....@mvps.org> wrote in message

news:OENn$UwbDH...@TK2MSFTNGP11.phx.gbl...

0 new messages