passing username entered on Login Windows onto php page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ansa
Forum Commoner
Posts: 31
Joined: Tue Aug 29, 2006 1:58 am
Location: Hamburg, Germany

passing username entered on Login Windows onto php page

Post by ansa »

Hi,

I was wondering if it is possible to get the username entered from a windows login. What I mean with windows login is an automatic pop-up login from the browser, when someone tries to access a certain folder.

What I would like to do is, to pass(or get) the username entered on this login window onto a php page, so I can manipulate the navigation depending on who has logged in.

I hope you guys can understand what I'm trying to do...
chakhar86
Forum Commoner
Posts: 45
Joined: Mon Jun 05, 2006 1:36 am
Contact:

Post by chakhar86 »

Try looking in PHP manual about server variables

$_SERVER[];
ansa
Forum Commoner
Posts: 31
Joined: Tue Aug 29, 2006 1:58 am
Location: Hamburg, Germany

Post by ansa »

I already thought of $_SERVER[], but I don't know what the variable name is for the user name. The thing is, I have to continue someone else's work. Is there a way to find out what the variable name is, or perhaps is it a fixed (reserved) variable name?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I believe $_SERVER['PHP_AUTH_USER']

http://us3.php.net/features.http-auth
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
chakhar86
Forum Commoner
Posts: 45
Joined: Mon Jun 05, 2006 1:36 am
Contact:

Post by chakhar86 »

I searched and found $_SERVER['PHP_AUTH_USER'], but i'm not so sure about it. Because it says that it'll provide you with username when you use http login authentification...

I found $_ENV variable though, it can retreive the shell (OS) environment vars, I think this is more like it.

But I don't know to use it
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

chakhar86 wrote:I searched and found $_SERVER['PHP_AUTH_USER'], but i'm not so sure about it. Because it says that it'll provide you with username when you use http login authentification...
Yes, but if not configured otherwise the Internet Explorer trys a ntml authentication with the current user's credentials - without confirmation of the user :(
There's no other way the webserver can automagically identifiy the windows logon user.
chakhar86 wrote:I found $_ENV variable though, it can retreive the shell (OS) environment vars, I think this is more like it.
The enviroment variables of the machine php is running on - the server, not the client.
ansa
Forum Commoner
Posts: 31
Joined: Tue Aug 29, 2006 1:58 am
Location: Hamburg, Germany

Post by ansa »

Yes, I have found out that PHP_AUTH_USER is the right variable name, have tested it and worked the way I wanted it.

Thanks.

I don't know any other or better solution for this. I could use $_SESSION, but that would mean I had to modify all the pages with session_start() and all.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply