Gossamer Forum
Home : General : Perl Programming :

Passing shadow password user ID to form

Quote Reply
Passing shadow password user ID to form
We are running Apache server and are using shadow password authentication to access certain areas of our site. We would like to pass the user ID entered during authentication to an HTML form. Since the shadow password authentication does not use .htaccess, but instead uses a perl module, I am puzzled on how to do this.

Any ideas?

Thanks
Quote Reply
Re: [thewebgeek] Passing shadow password user ID to form In reply to
What module?

Last edited by:

RedRum: Feb 22, 2002, 10:52 AM
Quote Reply
Re: [RedRum] Passing shadow password user ID to form In reply to
module = mod_auth_shadow.so

We are using a standard ID and password for Unix
Quote Reply
Re: [thewebgeek] Passing shadow password user ID to form In reply to
Hmm I'm not really sure how it works. Maybe $ENV{REMOTE_USER} would work?
Quote Reply
Re: [RedRum] Passing shadow password user ID to form In reply to
Actually it does. I now have the html page displaying the user ID. But I want to pass their user ID as a hidden field in a form that is on the page as well. Can I just set it like this:



<input type="hidden" name="IserID" value="$ENV{'REMOTE_USER'}">
Quote Reply
Re: [thewebgeek] Passing shadow password user ID to form In reply to
Yes you can do that.

BTW, how are you getting the ENV variable to print on a html page?....it must be cgi generated?

Last edited by:

RedRum: Feb 22, 2002, 11:04 AM
Quote Reply
Re: [RedRum] Passing shadow password user ID to form In reply to
Yes it is. I run the script as a server side include on my html page.
Quote Reply
Re: [RedRum] Passing shadow password user ID to form In reply to
Woops! I tried that and this is the output.

When I set my form input to this:

<input type="hidden" name="UserID" value="$ENV{'REMOTE_USER'}">

I get this as the output in the email that is generated

UserID = $ENV{REMOTE_USER}

What am I missing?
Quote Reply
Re: [thewebgeek] Passing shadow password user ID to form In reply to
You can't put an ENV in a html page, it must be cgi generated.

You'll need to use an SSI call to execute a script that returns the remote user variable

Last edited by:

RedRum: Feb 22, 2002, 12:14 PM
Quote Reply
Re: [RedRum] Passing shadow password user ID to form In reply to
I finally figured that out on my own.

I ended up putting the <input type="hidden" name="UserID" value="$ENV{'REMOTE_USER'}">

Inside the CGI script, then calling that inside the <form> tag on the html page via SSI.

Here is the whole cgi script:

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print <<EndHTML
<p>
<font face="Arial, Helvetica, sans-serif">
<font color="FF0000">
User ID is $ENV{'REMOTE_USER'}<p>
</font> </font>
<input type="hidden" name="UserID" value="$ENV{'REMOTE_USER'}">
EndHTML




As you can see, when the user goes to the page, they are also shown their user ID, which IMHO makes them feel a little more accountable. Not only that, the user ID is passed via the form, that way we can block certain functions for certain users. It keeps them from abusing our system.



Thanks for the help!!!