CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Can I find the username of someone accessing a perl script on our webserver?

 



Calab
Novice


Aug 28, 2012, 9:51 PM

Post #1 of 6 (1321 views)
Can I find the username of someone accessing a perl script on our webserver? Can't Post

I'd like to log the usernames of those who are running the scripts that I am creating.

In Perl, is there any way to determine the username of the person who is running my script?

Some givens...
- The scripts are only run through a web server.
- The web server is Apache 2, on a Linux 2.6.18-30 machine.
- All users are members of our Windows domain.

In ASP, I would use Request.ServerVariables ("LOGON_USER").


Laurent_R
Veteran / Moderator

Aug 29, 2012, 12:30 AM

Post #2 of 6 (1320 views)
Re: [Calab] Can I find the username of someone accessing a perl script on our webserver? [In reply to] Can't Post

Hi,

you can print the special variable $< or $> to your log file.


Calab
Novice


Aug 29, 2012, 12:41 AM

Post #3 of 6 (1319 views)
Re: [Laurent_R] Can I find the username of someone accessing a perl script on our webserver? [In reply to] Can't Post

Thanks, but that returns the userID than Apache is running under, not the username that the user used to log onto their Windows PC.


FishMonger
Veteran / Moderator

Aug 29, 2012, 6:35 AM

Post #4 of 6 (1308 views)
Re: [Calab] Can I find the username of someone accessing a perl script on our webserver? [In reply to] Can't Post

You can't get the user's local username in a cgi script.

The best you can do is to get their IP address and hostname, which may or may not be their own system.

What are you really needing to accomplish that led you to want to get their username?


Calab
Novice


Aug 29, 2012, 10:40 PM

Post #5 of 6 (1298 views)
Re: [FishMonger] Can I find the username of someone accessing a perl script on our webserver? [In reply to] Can't Post

I'm rewriting some of our old scripts. Many of our authentication systems are no longer used. One of them depended on the users username/password being valid. If the user gave false data the script would simply fail.

When a script was run, we would use the username in our catalogue to help identify who ran which instances of the script. (All output is logged to files and the catalogue is an index of those files)

Now this is no longer the case. The script execution does not require the username/password for the user. I can ask the user to enter their username on our form, but they could enter anything that they liked.

If possible, we'd like to find a reliable way to tag what user (or PC) executed the script.


FishMonger
Veteran / Moderator

Aug 30, 2012, 6:21 AM

Post #6 of 6 (1289 views)
Re: [Calab] Can I find the username of someone accessing a perl script on our webserver? [In reply to] Can't Post

Without an authentication process like what you used to use, you're left with using 2 cgi environment variables. $ENV{REMOTE_ADDR} and $ENV{REMOTE_HOST}
Neither of which are guaranteed to give you the info that you need/desire.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives