[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Need to get the USER that logged in...

I have a program that runs on a Secure server.  The user types in a URL that looks somewhat like this..

https://joe:snuffy@www.whatever.com/program.pl

I need program.pl to be able to get JOE out of that.  The server itself will take care of actually authenticating the user, I just want to be able to grab the user name.  I thought $ENV{REMOTE_USER} was the way to get that but so far it isn't working..
Is that the correct way to get that information and if not, how do I get it?

Thanks

-Pal

0
Palamedes
Asked:
Palamedes
1 Solution
 
guadalupeCommented:
Try this code:

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

foreach (keys %ENV)
{
print "Key: $_  ==> Value: $ENV{$_}<br>";
}


It will show you what vars are available.  Make sure to put it in a protected place that forces a log in and ten you'll see if an env var is being created by you server which will work.  Remember that not all servers create the same CGI Env Vars so this shows what ones DO exists.
0
 
maneshrCommented:
try this

#!/usr/local/bin/perl

use CGI;

print "Content-type: text/html\n\n";

$ENV{SERVER_URL}="https://joe:snuffy\@www.whatever.com/program.pl";

$ENV{SERVER_URL}=~ /https:\/\/(.*):.*@.*/;
print $1,"<br>\n";  ##OUPUT will be joe

#### OR YOU CAN USE THIS#########
@tmp=split(/:/,$ENV{SERVER_URL});
$tmp[1]=~ s/\/\///g;
print $tmp[1],"<br>\n";##OUPUT will be joe
0
 
PalamedesAuthor Commented:
Thanks Guadalupe.. Thank showed it.. it's AUTH_USER  ... sheesh..

-Pal

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now