473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Getting username

Bob
My directory uses .htaccess authorization by requiring a username and
password. I want to keep a simple log of all transactions to a DB which
will provide the who-what-when-where for all edit/add/delete
operations. To this end, I want to obtain the username provided in the
..htaccess login. I've tried $PHP_AUTH_USER and $PHP_REMOTE_USER but
both variables are blank.

How can I get the username?

Sep 20 '06 #1
10 6730
Bob wrote:
My directory uses .htaccess authorization by requiring a username and
password. I want to keep a simple log of all transactions to a DB
which will provide the who-what-when-where for all edit/add/delete
operations. To this end, I want to obtain the username provided in the
.htaccess login. I've tried $PHP_AUTH_USER and $PHP_REMOTE_USER but
both variables are blank.

How can I get the username?
$_SERVER["REMOTE_USER"]

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Sep 20 '06 #2
Kim André Akerĝ wrote:
Bob wrote:
My directory uses .htaccess authorization by requiring a username
and password. I want to keep a simple log of all transactions to a
DB which will provide the who-what-when-where for all
edit/add/delete operations. To this end, I want to obtain the
username provided in the .htaccess login. I've tried $PHP_AUTH_USER
and $PHP_REMOTE_USER but both variables are blank.

How can I get the username?

$_SERVER["REMOTE_USER"]
My bad; $_SERVER["PHP_AUTH_USER"].
(I'm just too used to CGI on that part, I guess.)

$PHP_AUTH_USER won't work unless register_globals is set to "on" in the
PHP configuration.

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Sep 20 '06 #3
Bob

Kim André Akerĝ wrote:
My bad; $_SERVER["PHP_AUTH_USER"].

$PHP_AUTH_USER won't work unless register_globals is set to "on" in the
PHP configuration.
I set register_globals ON. When I logged in and ran this script:

<?php
$auser = $_SERVER["PHP_AUTH_USER"];
echo 'Current user is'.$auser.'<BR>';
?>

The user was blank!!

Have any idea what's wrong here?

Sep 20 '06 #4
Bob

Kim André Akerĝ wrote:
My bad; $_SERVER["PHP_AUTH_USER"].

$PHP_AUTH_USER won't work unless register_globals is set to "on" in the
PHP configuration.
I set register_globals ON. When I logged in and ran this script:

<?php
$auser = $_SERVER["PHP_AUTH_USER"];
echo 'Current user is'.$auser.'<BR>';
?>

The user was blank!!

Have any idea what's wrong here?

Sep 20 '06 #5
Bob wrote:
Kim André Akerĝ wrote:
>>My bad; $_SERVER["PHP_AUTH_USER"].

$PHP_AUTH_USER won't work unless register_globals is set to "on" in the
PHP configuration.


I set register_globals ON. When I logged in and ran this script:

<?php
$auser = $_SERVER["PHP_AUTH_USER"];
echo 'Current user is'.$auser.'<BR>';
?>

The user was blank!!

Have any idea what's wrong here?
First of all, you need to set register_globals to OFF. Having it on is
a potential security threat, which is why it now defaults to off.

Are you trying this from a protected directory? What happens if you put
a file containing

<?php
phpinfo();
?>

(only) in a protected directory? Do you see the authorized user there?

Also, what web server are you using?

It should show up in both $_SERVER['PHP_AUTH_USER'] (the best to use)
and $_SERVER['REMOTE_USER'] (which may or may not be authorized).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '06 #6
Bob

Jerry Stuckle wrote:
Are you trying this from a protected directory? What happens if you put
a file containing

<?php
phpinfo();
?>

(only) in a protected directory? Do you see the authorized user there?

Also, what web server are you using?

It should show up in both $_SERVER['PHP_AUTH_USER'] (the best to use)
and $_SERVER['REMOTE_USER'] (which may or may not be authorized).
Hi Jerry - Yes, I'm in a protected directory - OS is Apache. phpinfo()
showed me that the username appears in:

$_SERVER["REMOTE_USER"]

but not in $_SERVER['REMOTE_USER']

Thank your very much for your help.

Sep 20 '06 #7
Bob

Jerry Stuckle wrote:
First of all, you need to set register_globals to OFF. Having it on is
a potential security threat, which is why it now defaults to off.

$_SERVER['REMOTE_USER'] worked with register_globals both ON and OFF.
I left it to OFF as everyone has suggested.

Sep 20 '06 #8
Bob

Jerry Stuckle wrote:
Are you trying this from a protected directory? What happens if you put
a file containing

<?php
phpinfo();
?>

(only) in a protected directory? Do you see the authorized user there?

Also, what web server are you using?

It should show up in both $_SERVER['PHP_AUTH_USER'] (the best to use)
and $_SERVER['REMOTE_USER'] (which may or may not be authorized).

Hi Jerry - Yes, I'm in a protected directory - OS is Apache. phpinfo()
showed me that the username appears in:

$_SERVER["REMOTE_USER"]
but not in $_SERVER['PHP_AUTH_USER']
Thank your very much for your help.

Sep 20 '06 #9
Bob wrote:
Jerry Stuckle wrote:

>>First of all, you need to set register_globals to OFF. Having it on is
a potential security threat, which is why it now defaults to off.

$_SERVER['REMOTE_USER'] worked with register_globals both ON and OFF.
I left it to OFF as everyone has suggested.
Yes, $_SERVER['REMOTE_USER'] works either way. With register_globals
on, either $_SERVER['REMOTE_USER'] or $REMOTE_USER works.

The problem comes in when someone uses a url such as:

http://www.example.com/admin?REMOTE_USER=admin

This would also set $REMOTE_USER, but not $_SERVER['REMOTE_USER']

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '06 #10
Bob wrote:
Jerry Stuckle wrote:

>>Are you trying this from a protected directory? What happens if you put
a file containing

<?php
phpinfo();
?>

(only) in a protected directory? Do you see the authorized user there?

Also, what web server are you using?

It should show up in both $_SERVER['PHP_AUTH_USER'] (the best to use)
and $_SERVER['REMOTE_USER'] (which may or may not be authorized).

Hi Jerry - Yes, I'm in a protected directory - OS is Apache. phpinfo()
showed me that the username appears in:

$_SERVER["REMOTE_USER"]
but not in $_SERVER['PHP_AUTH_USER']
Thank your very much for your help.
Strange - it should be in both. How are you doing the authentication?
Just .htaccess/.htpasswd or something else?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Derek Martin | last post by:
Using VB.Net, I would like to retrieve the currently logged in user's DN from Active Directory. Alternatively, if, using WindowsIdentity, or something similar, I would like to get the user's full...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
2
by: PHP_Paul | last post by:
Ok, I'm trying to poineer into the wonderful area of PHP/MySQL programming, but I'm having some difficulties. http://www.paulhq.com/php/freepage.html should register, but when anyone fills something...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
5
by: dgleeson3 | last post by:
Hello all I have used the LoginForm1 class in a Visual studio 2005 VB application. Its the standard Username, Pasword request for user input. I was hoping to use property procedures to get...
10
by: priyakollu | last post by:
hi guyz! please help me in sorting out error as im unable to find it... my requirement is there will be userid field and password field and "login" button after clicking button certain validations...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
6
NawazAhmed
by: NawazAhmed | last post by:
Hi, I was trying to get local system's username in my code behind. I tried every almost possible way. Here is the scenario: My project is web based and I don't have a login screen....I need to get...
4
by: icarus | last post by:
global_vars.py has the global variables set_var.py changes one of the values on the global variables (don't close it or terminate) get_var.py retrieves the recently value changed (triggered right...
8
by: tiijnar | last post by:
Hi, To get windows username Im using the following code. public class GetWindowUsername { public String getUser() { String userName = System.getProperty("user.name");...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.