Hi guys,

Even though I've been working in Perl for about 20 years, I've stumbled upon a challenge I can't really get my head around yet. Let me outline the problem.

I've written some web-based support tools in Perl that I can run on localhost (also via a HTTP::Server::Simple webserver I wrote). However, each employee has different authorisations on the database servers: some can access databases A and B, others A, B and C, etc.

Now we want the IIS server that will be used for these tools to use Windows Basic Authentication, so people will automatically be recognized and the permissions for the web server will be set accordingly. But each database requests that is generated by the Perl scripts, should inherit this authentication and send off requests to the MS SQL server using the user's authentication.

How can I get the authentication values into my Perl script from IIS and use these to fire off requests to the MS SQL database with those same authentication values? Can I perhaps access the user's data via LDAP somehow?

Btw: the MS SQL database connection also uses Windows Basic Authentication; the connect string I use personally for my scripts is:
     my $dbh = DBI->connect( "DBI:ODBC:driver={SQL Server};Server=$server;Database=$database;");

I expect I will be able to access the username via HTTP environment variables, but not the password. Those two are probably necessary to access the database with the user's credentials. So I'm stuck unless I start gathering passwords from users. Which of course is a security no-no. And asking a user to type in his password in a password field for each click isn't the way to go IMHO.

Is there a way to inherit the windows authentication in Perl to access the database with the user's credentials that he used to access the IIS server?

Hope you can help!


In reply to Inheriting IIS Windows Basic Authentication on webserver to underlying MS SQL Perl database connection by eelkonio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.