Finding Directory Corresponding To Domain Name
Finding Directory Corresponding To Domain Name
am 05.07.2007 01:35:11 von Le Chaud Lapin
Hi All,
I have an EXE that runs on the same machine as IIS, and that EXE
receives HTTP requests over the Internet, which I intend to forward
directly to IIS. However, just before forwarding the requests, I
would like to extract the domain name specified in the URL by the
client, and use that domain name to find the associated root directory
of web site managed by IIS.
Two questions:
1. I know that, for a long-time now with a new HTTP protocol (forget
which), the client is required to include the domain name of the URL
in the HTTP GET request itself. What do people call this feature?
2. There is an easy way and a hard way (and probably many ways in
between) to find the root directory of the web site corresponding to a
web site on a virtually-hosting server. What is the easy way?
-Le Chaud Lapin-
Re: Finding Directory Corresponding To Domain Name
am 05.07.2007 02:48:30 von Ken Schaefer
"Le Chaud Lapin" wrote in message
news:1183592111.289312.198810@r34g2000hsd.googlegroups.com.. .
> Hi All,
>
> I have an EXE that runs on the same machine as IIS, and that EXE
> receives HTTP requests over the Internet, which I intend to forward
> directly to IIS. However, just before forwarding the requests, I
> would like to extract the domain name specified in the URL by the
> client, and use that domain name to find the associated root directory
> of web site managed by IIS.
>
> Two questions:
>
> 1. I know that, for a long-time now with a new HTTP protocol (forget
> which), the client is required to include the domain name of the URL
> in the HTTP GET request itself. What do people call this feature?
Client is not required to send anything. But HTTP v1.1 (the current version
of HTTP) supports the concept of virtual hosts (multiple web sites running
on a single IP/port combination). The client sends a Host: HTTP header that
indicates the HTTP virtual host it wishes to connect to.
> 2. There is an easy way and a hard way (and probably many ways in
> between) to find the root directory of the web site corresponding to a
> web site on a virtually-hosting server. What is the easy way?
Just query the IIS metabase. You can do this via WMI, or IIS ADSI provider.
Cheers
Ken
Re: Finding Directory Corresponding To Domain Name
am 05.07.2007 07:19:29 von Le Chaud Lapin
On Jul 4, 7:48 pm, "Ken Schaefer"
wrote:
> > 2. There is an easy way and a hard way (and probably many ways in
> > between) to find the root directory of the web site corresponding to a
> > web site on a virtually-hosting server. What is the easy way?
>
> Just query the IIS metabase. You can do this via WMI, or IIS ADSI provider.
Thanks, Ken. For others who are interested ,this appears to be a
related link: http://msdn2.microsoft.com/en-us/library/ms524682.aspx
I have two more questions. I intend to write an EXE that will write
log data to the root directories of each virtual site that is being
hosted on the IIS server.
1. Given that my EXE will likely be run in same account as IIS,
should I expect any trouble with permissions?
2. For each individual web site, will all the CGI-like code
(applications?) have access to that log data in their root directories
as they get executed?
-Le Chaud Lapin-
Re: Finding Directory Corresponding To Domain Name
am 05.07.2007 08:29:59 von David Wang
On Jul 4, 10:19 pm, Le Chaud Lapin wrote:
> On Jul 4, 7:48 pm, "Ken Schaefer"
> wrote:
>
> > > 2. There is an easy way and a hard way (and probably many ways in
> > > between) to find the root directory of the web site corresponding to a
> > > web site on a virtually-hosting server. What is the easy way?
>
> > Just query the IIS metabase. You can do this via WMI, or IIS ADSI provider.
>
> Thanks, Ken. For others who are interested ,this appears to be a
> related link:http://msdn2.microsoft.com/en-us/library/ms524682.aspx
>
> I have two more questions. I intend to write an EXE that will write
> log data to the root directories of each virtual site that is being
> hosted on the IIS server.
>
> 1. Given that my EXE will likely be run in same account as IIS,
> should I expect any trouble with permissions?
> 2. For each individual web site, will all the CGI-like code
> (applications?) have access to that log data in their root directories
> as they get executed?
>
> -Le Chaud Lapin-
I don't know what you are really trying to do.
For example, I do not understand why you need to write an EXE to do
this. A global ISAPI Filter will work just fine. And you don't need to
read the IIS metabase to figure out what you need --
- the HTTP_HOST server variable gives you the Host header
- the PATH_TRANSLATED server variable gives the physical path of the
URL
- you can also call HSE_REQ_MAP_URL_TO_PATH_EX to retrieve the URL-to-
physical path mapping.
Whether applications have access to that log data depends on the user
identity that the application runs as, and the user identity you use
to write the log data. Everything is configurable, so it may be
possible, or it may not, depending on your actual requirements.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
Re: Finding Directory Corresponding To Domain Name
am 05.07.2007 19:51:26 von Le Chaud Lapin
On Jul 5, 1:29 am, David Wang wrote:
> I don't know what you are really trying to do.
>
> For example, I do not understand why you need to write an EXE to do
> this. A global ISAPI Filter will work just fine. And you don't need to
> read the IIS metabase to figure out what you need --
> - the HTTP_HOST server variable gives you the Host header
> - the PATH_TRANSLATED server variable gives the physical path of the
> URL
> - you can also call HSE_REQ_MAP_URL_TO_PATH_EX to retrieve the URL-to-
> physical path mapping.
>
> Whether applications have access to that log data depends on the user
> identity that the application runs as, and the user identity you use
> to write the log data. Everything is configurable, so it may be
> possible, or it may not, depending on your actual requirements.
Being able to use HSE codes would make things a bit easier, but
unfortunately, the EXE that I am making will be running on public web
servers, and I cannot afford to bring down a web server because my DLL
was buggy. The EXE, receiving and making connections over the
Internet, will be somewhat sophisticated in its own right, and being
able to start and stop the EXE (easily) might be a benefit. It will
also have a GUI.
I guess it is possible to achieve much of this using a DLL, but I had
a problem with the DllMain mutex locking issue a while back, and it
left a bad taste in my mouth.
-Le Chaud Lapin-
Re: Finding Directory Corresponding To Domain Name
am 05.07.2007 20:08:16 von Le Chaud Lapin
On Jul 5, 12:51 pm, Le Chaud Lapin wrote:
> On Jul 5, 1:29 am, David Wang wrote:
>
> > I don't know what you are really trying to do.
>
> > For example, I do not understand why you need to write an EXE to do
> > this. A global ISAPI Filter will work just fine. And you don't need to
> > read the IIS metabase to figure out what you need --
> > - the HTTP_HOST server variable gives you the Host header
> > - the PATH_TRANSLATED server variable gives the physical path of the
> > URL
> > - you can also call HSE_REQ_MAP_URL_TO_PATH_EX to retrieve the URL-to-
> > physical path mapping.
>
[snip]
> I guess it is possible to achieve much of this using a DLL, but I had
> a problem with the DllMain mutex locking issue a while back, and it
> left a bad taste in my mouth.
>
I should have given more context in my response:
The point of insertion of my EXE between the web client and IIS needs
to be external to IIS. The reason is that the web client is not a
traditional client, but a custom client, and the protocol is not TCP/
IP, but something else, something old, so packets will be arriving at
the web server over this alternate protocol, at which point the EXE
will forward the requests to IIS.
-Le Chaud Lapin-