Page 1 of 1

HTTP-Authentication and Windows

Posted: Tue Nov 19, 2002 2:07 pm
by Data
I have Apache and PHP installed on Windows XP Home.
I've been trying to do some basic http-authentication:

Code: Select all

<?php
if (!isset($PHP_AUTH_USER)) 
{
	// If empty, send header causing dialog box to appear
	header('WWW-Authenticate: Basic realm="My Private Stuff"');
	header('HTTP/1.0 401 Unauthorized');
	echo 'Authorization Required.';
	exit;
}
else 
{
	echo "<p>You have entered this username: $PHP_AUTH_USER<br>";
	echo "You have entered this password: $PHP_AUTH_PW<br>";
	echo "The authorization type is: $PHP_AUTH_TYPE<p>";
}

?>
I'm sure that this should work correctly (I am not outputting anything before the header), however I always get a 500 Internal Server Error.
Will HTTP-Authentication work in Windows?

Posted: Tue Nov 19, 2002 10:13 pm
by hedge
no, it doesn't work on windows. you need to authenticate against a db or some other method.

Posted: Wed Nov 20, 2002 2:27 am
by twigletmac
If you're running PHP as an Apache module the HTTP-authentication should be available to you even if you are on Windows.
http://www.php.net/manual/en/features.http-auth.php

The problem is likely to be that you should be using things like $_SERVER['PHP_AUTH_USER'] instead of $PHP_AUTH_USER - check the examples shown in the link above which have been written to work in the latest versions of PHP where register_globals (viewtopic.php?t=511) is off by default.

Mac

Posted: Wed Nov 20, 2002 1:57 pm
by hedge
Sorry for the mis-information. I didn't read close enough, and assumed IIS