Forum Moderators: coopster

Message Too Old, No Replies

(!isset($ server['php auth user']))

Can't get it to work on Windows 2003 and PHP 5.2.5

         

Dwaarrt

10:28 pm on Mar 22, 2008 (gmt 0)

10+ Year Member



ok, rehash of old question. I have tried all the examples I have found on this topic, and same problem:

I get the logon box, no matter what I enter it still comes back 3 times, then says unauthorized.

Using Apachee IS NOT AN OPTION! There is nothing wrong with Apachee, it is a great server... it just doesn't run asp or aspx... and many other sites on this server use that. I own the server... so I am also the Admin... can change whatever I need to so long as I know why and what effect it has on security.

Below is a junk block of code... just to illustrate my situation.
Mind you it is not good code, nor close to what I am doing, but the problem is in the first part...

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

// change this value to the User Name you want to use:
$user_name = "admin";

// change this value to the password you want to use:
$password = "password";

if (!isset($_SERVER['PHP_AUTH_USER'])) {
//If empty send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="Editable Files"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization required.';
echo ('User name entered was: ' . $_SERVER['PHP_AUTH_USER'] . 'Password was: ' . $_SERVER['PHP_AUTH_PW'] . '<br />');

exit;
} else {
echo ('User name entered was: ' . $_SERVER['PHP_AUTH_USER'] . 'Password was: ' . $_SERVER['PHP_AUTH_PW'] . '<br />');

}
?>

It doesn't return any user name or password.
You can find the user name with $_SERVER[AUTH_USER] but the $_SERVER[AUTH_PASSWORD] is still blank...

The $_SERVER[PHP_AUTH_PW] is also blank.

Realy need a heads up on this one... Microsoft says they can't help since I am running PHP...

eelixduppy

5:00 am on Mar 23, 2008 (gmt 0)



Welcome to WebmasterWorld!

What you are showing me doesn't make much sense as to why it isn't working for you. From the code that I see, it should be working. I would try turning up error reporting [php.net] and checking your logs for anything that may be going wrong with this script that we can identify. You might also want to take a look at php's documentation of http authentication because there are some notes about http authentication with php and iis: [php.net...]

see what that gives you