IIS7.0 How to use C++ programs that compile to .cgi files [Answered]RSS

3 replies

Last post Nov 08, 2007 07:56 PM by rickjames

  • IIS7.0 How to use C++ programs that compile to .cgi files

    Nov 05, 2007 09:24 AM|cuff@interware.net|LINK


    I have a web application with the following design.

    The site root is c:\website

    There are 1000 subdirectories that run sites within.

    All activity is run from about 12 programs in c:\website\cgi-bin 

    These programs are all compiled in C++ and have an extension .cgi.

    They are server side executables.

    My site is currently on IIS5.0 and I want to move to IIS7.0

    FastCGI also looks attractive.  I thought I would set up an application pool per program.

    Two of the 12 programs are used almost 95% of the time - one is 75% of the 95%.

    In IIS7.0 the Handler Mappings and Script maps insist the executable ends in exe or dll.

    Any idea how I work around this.

    Second question 

    My application has it's own security system (like the new builtin Membership forms authentication).

    Once I authenticate to my login I want to provide a link that connects and does a single Windows authentication to a separate site.

    I want to do this invisibly - the user clicks my link and he is authenticated by my one global login to the site.  I want to keep this protetcted so that only after autheticating to my site can access be gained to the other (remote) site.  Any suggestions how I might accomplish this.

    My last problem is to understand how to spawn another program such as an exe from my cgi executable.


    Thanks for any help you can offer!




    FastCGI IIS7

  • Re: IIS7.0 How to use C++ programs that compile to .cgi files

    Nov 05, 2007 12:54 PM|rickjames|LINK

    Hi cuff,

    I just tried renaming php-cgi.exe to php-cgi.CGI and PHP continues to work for me. Could you elaborate on the insistence of IIS 7?

    I don't know the best way to perform authentication and authorization as you describe. Note that it is the browser that chooses when to pop a login window and when to just pass credentials automatically (In IE, I think it this is configurable on the security tab).

    If you have a C++ program and want to spawn a process, checkout the CreateProcess API on MSDN.



  • Re: IIS7.0 How to use C++ programs that compile to .cgi files

    Nov 08, 2007 01:25 PM|cuff@interware.net|LINK

    Hi Rick:

    Here are the steps I have done (all in IIS Manager)
    One has to guess at the what the correct setup logic really is.
    - my intution is set forth below

    Under Server - ISAPI and CGI Restrictions I added the path and name of my 11 programs and "allowed"

    Under Server - Handler Mappings I changed CGI-exe from *.exe to *.cgi (CgiModule)
    as per your first comment.

    No FastCgi at this point.

    Under Server - I added a MIME type .cgi application/octet-stream

    Under Application Pools I add 1 pool for each application I have  (15 pools)

    Under Sites  MywebSite (there is the default and Mywebsite)
    MYwebsite has 1300 subdirectories.

    In this directory are 11 .cgi applications + 3 DLL's + an exe
    These programs together run the whole application and site.

    It appears in IIS manager that only The site "Mywebsite" at the root
    gets an action on the right View applications.
    I click this and get Add Application
    A dialogue box comes up and asks for the "Alias" App Pool and path of the directory.
    The word alias has me stumped but I think it is asking me the name of my program
    i.e. program.cgi  - I select the pool I made for this application
    If alias is not the program name I have no idea how you tie a program to an app pool.
    I give the physical path d:\mywebsite\cgi-bin
    I assume I select Connect as Application user (pass-through authentication)
    But when I Test settings I get a meassage
    Okay on Pass-through authetication to ProgPool:NetworkService
    Failure on Authorization Cannot verify access to path D;\mywebsite\cgi-bin
    To make it work to proceed I connect as the Administrator for now until I resolve this.
    This works The administrator is the only account I know the password.
    This process also makes a Virtual Path /program.cgi  - this also makes no sense
    My site runs like this


    Under Mywebsite the only one below the Defauft Site
    I goto d:\website\cgi-bin
    In this directory are 11 .cgi applications + 3 DLL's + an exe
    In IIS manager under mysite\cgi-bin

    Now I think I want to add Handler mappings

    I click on Handler Mappings

    On the actions panel I now click Add Module Mapping

    Request path = Program.cgi (my guess from the example *.bas, wsvd.axd)
    The work Path has a different meaning for me and suggests the directory
    but the example suggests an extension.

    I assume I would do 1 per program program1.cgi through program11.cgi
    Then I would select the Module (the Module: prompt and select box does make sense)
    I select Modules either cgi or Fastcgi

    Executable Optional  this allows only a dll or a exe as per my first post
    My programs end in cgi
    It does allow me to select Module cgi but if I select module FastCGi
    it gives an error insisting this must be an exe.
    I have no idea how I could use FastCGI since my extension is .cgi


    In terms of my other question.   I have a user autheticate to my system via my C++ programs above

    I then want to redirect him and autheticate him to a remote site invisibly.

    The remote site would have a single login/password that only I would know.

    I do not want the user to do any further step once he authenticates to my system.  At that point he is entiltled to user the other site.

    Thanks !!!! 




    FastCGI IIS7 500

  • Re: IIS7.0 How to use C++ programs that compile to .cgi files

    Nov 08, 2007 07:56 PM|rickjames|LINK

    Hi Scuff,

    It appears that you are not using FastCGI, so please use a different forum in future..

    Here is the process to get a CGI running as .cgi to work on IIS 7:
    1) start - run - inetmgr - Sites - Default Web Site - Handler Mappings
    2) (Actions, on the right) Add Module Mapping - *.cgi - CgiModule - <blank> - dot cgi
    3) (Tree, on the left) <machine name> - ISAPI and CGI Restrictions - <full path to cgi> - <friendly name> - check allow


    PS. Do not add a CGI to MIME types, this will allow the executable to served as a static file