in reply to Re: remote_user not identifing user
in thread remote_user not identifing user

It is password protected (HTTP authentication) and no I have not changed web servers ever. could it just be a problem with the hosting site?
  • Comment on Re: Re: remote_user not identifing user

Replies are listed 'Best First'.
Re: Re: Re: remote_user not identifing user
by dws (Chancellor) on Jan 17, 2002 at 22:31 UTC
    It is password protected (HTTP authentication) and no I have not changed web servers ever. could it just be a problem with the hosting site?

    Yes, it could be.

    As a diagnostic, try adding a simple "echo" script to dump the environment.

    #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<html><body><pre>"; foreach my $key ( sort keys %ENV ) { print $key, ": ", $ENV{$key}, "<br>\n"; } print "</pre></body></html>\n";
    will get you most of the way there. If you need to supply a password to get to the script, and it doesn't display REMOTE_USER, then your provider may have changed web server settings.

      I checked the %ENV with the diagnostic script it shows REMOTE_USER is there and has the correct value. However it still does not capture the value for my script. What is wrong. Again if I set $user equal to a value it works if I try to capture the remote_user with either the %ENV or the CGI function it will not work either way.
      #!/usr/bin/perl -w #Volunteer.pl - Insert Volunteers into database use strict; use DBI; use CGI; my $query = CGI::new(); my ($dbh, $sth, $sql, $name, $date, $sub_parent, $col); my @volunteer_date = $query->param("Volunteer"); my $parent = $query->param("Parent"); #my $user = $query->REMOTE_USER(); my $user = $ENV{"REMOTE_USER"}; #my $user = "<Player Name>"; #my $name = undef; #my $parent = "Father"; #my @volunteer_date = ("2002-01-18"); print $query->header(), $query->start_html (-title=>'Volunteer List Form', -link=>'#FFFFFF', -vlink=>'99FF99', -alink=>'black', -style=>{'-src'=>'/CSS/stylesheet.css'});
      database connection goes here.
      # store subparent for each parent my %parent_hash = ( 'Father' => 'Mother', 'Mother' => 'Father' ); if ( @volunteer_date ){ if (exists $parent_hash{$parent}) { my $sub_parent = $parent_hash{$parent}; for $col ( $parent, $sub_parent ) { $sql = "select $col from Roster where User=?"; $sth = $dbh->selectcol_arrayref( $sql, undef, $user ); print $query->h1({-align=>'center'},"$sub_parent, $parent, $user"); if ( @$sth && $sth->[0] ) { # any rows returned? $name = $sth->[0]; # take first one #last; } } } print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name"); foreach $date ( @volunteer_date ) { $sql = "select distinct Volunteer from Volunteer where Volunte +er =? and Date =?"; my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date +); #Verify the parent is not signed up. if( @$sth ) { print $query->h1({-align=>'center'}, "You are already sig +ned up for this date: $date"); last; } } } print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name"); foreach $date ( @volunteer_date ) { $sql = "select distinct Volunteer from Volunteer where Volunte +er =? and Date =?"; my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date +); #Verify the parent is not signed up. if( @$sth ) { print $query->h1({-align=>'center'}, "You are already sig +ned up for this date: $date"); last; } #end if statement #process the information and update the schedule. else{ my $sql = "select max(Number) from Volunteer where Date =? and + Volunteer = 'TBD'"; my $number = $dbh->selectcol_arrayref($sql, undef, $date); $sql = "update Volunteer set Volunteer = '$name' WHERE Date = +'$date' and Number = $number->[0]"; $sth = $dbh->prepare($sql) || die "prepare: $$sql: $DBI::errst +r"; $sth->execute || die "execute: $sql->[0]: $DBI::errstr"; print $query->h1({-align=>'center'}, "You signed up for this d +ate $date"); $sth->finish (); $dbh->disconnect (); } #end else statement } #end foreach loop } #end if volunteer_date check else{ print $query->h1({-align=>'center'}, "You did not select a dat +e"); } #end else volunteer_date check # print $query->end_html; print $query->h2({-align=>'center'}, $query->a({href=>'../UnSignup.pl'}, 'UNDO SIGNUP'), '&nb +sp', $query->a({href=>'../BobSchedule.pl'}, 'BOBS SCHEDULE'), + '&nbsp',); $query->end_html; print $query->h3({-align=>'center'}, $query->a({href=>'Volunteer.pl'}, 'BACK'), '&nbsp',); $query->end_html;
        I checked the %ENV with the diagnostic script it shows REMOTE_USER is there and has the correct value. However it still does not capture the value for my script.

          my $user = $ENV{"REMOTE_USER"}; should be picking up the username if the diagnostic script shows that it's there. When you set $user yourself, are you using exactly the same username that the diagnostic script prints?

        Were this me, I would do

        print $query->header(), $query->start_html (-title=>"Volunteer List Form ($user)", ...
        to verify what I'm getting. Then I'd focus on the query logic.