Enable Windows Authentication in a PHP website

Hosting your PHP site in IIS server is easy way to enable Windows Authentication.

Let's see How to install PHP 5.3 on IIS 7
I downloaded PHP for windows from http://windows.php.net/download/

Run the exe and start installation.























Then click next and accept the terms and conditions go next.

Then select IIS FastCGI option.






















Select features and extensions you want.

There is an another tool called PHP manager.If u install it you can easily change PHP configuration.
I download that software from http://phpmanager.codeplex.com/

After installing it appears in IIS.You can change configurations such as php.ini configurations enable disable extensions etc.






























Now go to authentication window by clicking authentication icon.












Then you can see authentication types. Right click on Windows Authentication and click Enable.

Now you can use server variables to get logged user name.
$userId=$_SERVER['REMOTE_USER'];
It will return YOUR_DOMAIN\USERNAME


1 comment:

  1. A very useful post, note that you first have to have enabled Windows Authentication when installing IIS (http://forums.iis.net/t/1160068.aspx)

    ReplyDelete