Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

CGI Page and REMOTE_USER environment variable

by Anonymous Monk
on Nov 09, 2012 at 11:51 UTC ( [id://1003106]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have following code which tries to read the REMOTE_USER environment variable passed by IE to the server, but it's not working:
use strict; use warnings; use CGI; my $q = CGI->new(); my $UserID = $ENV{"REMOTE_USER"}; print $q->header(); if($UserID){ print "User:<b>$UserID</b>"; }
The apache log shows
[error] Bad/Missing NTLM/Basic Authorization Header for /testarea/test +.pl [6275] AuthenNTLM: timed outwhile waiting for lock (key = 23754)
Anyone has some sugestion how to make this simple script work, or where to start debug?

Replies are listed 'Best First'.
Re: CGI Page and REMOTE_USER environment variable
by bart (Canon) on Nov 09, 2012 at 12:27 UTC
    The error message your seeing is totally unrelated to the code of this script. In fact you'll probably see it for any script. Look for the cause outside of this small world that you're currently looking at.
Re: CGI Page and REMOTE_USER environment variable
by roboticus (Chancellor) on Nov 09, 2012 at 12:03 UTC

    I don't do any CGI or WWW stuff in perl, but a brief review of the CGI docs indicates that you can use the remote_user() method to get the remote user's name. As I see it, you're trying to access the environment variable REMOTE_USER on the server.

    Also, the log shows a basic authentication problem, so you may be having trouble a bit before your code gets a chance to do much. I think I'd track down one of the CGI tutorials, or investigate one of the newer perl WWW frameworks that people are talking about.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      my $q = CGI->new(); #my $UserID = $ENV{"REMOTE_USER"}; my $UserID = $q->remote_user(); print $q->header(); if($UserID){ print "User:<b>$UserID</b>"; }
      I get nothing in the page and the same error in the logs.

        It works for me (with shebang) on IE and Firefox.

        Smells like Apache2-AuthenNTLM

        «The Crux of the Biscuit is the Apostrophe»

Re: CGI Page and REMOTE_USER environment variable
by Anonymous Monk on Nov 09, 2012 at 12:25 UTC
    CGI doesn't have much to do with AuthenNTLM, whatever software is responsible for that NTLM stuff is where the problem lies

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1003106]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found