note 2003 deleted from features.http-auth by irc-html

From: Date: Sat, 19 Jan 2002 20:25:53 +0000
Subject: note 2003 deleted from features.http-auth by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25302@lists.php.net to get a copy of this message
I found a way to do the Basic Authentication on IIS anyway.<BR> You have to disable the built-in Authentication from IIS first to make it wotk though (only enable "Allow Anonymous Access", disable the other Authentication methods).<BR> Here's a code extract that works on IIS as well as on other webservers (like Apache):<PRE> if ($PHP_AUTH_USER == "" && $PHP_AUTH_PW == "" && ereg("^Basic ", $HTTP_AUTHORIZATION)) { list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(":", base64_decode(substr($HTTP_AUTHORIZATION, 6))); } $authenticated = 0; if ($PHP_AUTH_USER != "" || $PHP_AUTH_PW != "") { //put your authentication here (e.g. database lookup) $authenticated = ($PHP_AUTH_USER == "test" && $PHP_AUTH_PW = "123"); } if(!$authenticated) { header("WWW-Authenticate: Basic realm=\"DB-Admin\""); if (ereg("Microsoft", $SERVER_SOFTWARE)) header("Status: 401 Unauthorized"); else header("HTTP/1.0 401 Unauthorized"); echo "Access denied"; exit; } </PRE>And we're another step further in writing platform/webserver independent PHP code...<BR> &nbsp; &nbsp; Brecht Sanders (<A HREF="http://brecht.sanders.org/" TARGET="_blank">http://brecht.sanders.org/</A>)

« previous php.notes (#25302) next »