Is there a way to have a login authorisation via IIS 7?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
v2jtb
Forum Newbie
Posts: 1
Joined: Tue Nov 24, 2009 10:53 am

Is there a way to have a login authorisation via IIS 7?

Post by v2jtb »

I am not a programmer and how this all started was that I wanted to have an area on my home website that you can log in and out. I have had a real learning curve when it has come to the installation of PHP, MYSQL, IIS 7 , Fast CGI, PEAR, Smarty and phpMyAdmin. Not to mention the configuration of the above software and different versions, it has been a nightmare but real enjoyable when you see your PHPinfo file working.
I have bought quite a few books including “PHP and MySQL Web Development (4th Edition) (Developers Library) by Laura Thomson” which is really good.
The book has exactly what I want with regards to a login (authorisation :banghead: ) scripts but it uses apache .htaccess files and I am assuming as I use IIS 7 (Vista Ultimate) this is the reason it will not work. I really don’t want to start trying to install another program.
Every book I have bough seems to use Apache but as my website is hosted by Godady.com and I opted for the windows option as I know windows.
Is there a way to have a login via IIS 7?
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Re: Is there a way to have a login authorisation via IIS 7?

Post by ambivalent »

Code: Select all

if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) 
    && $_SERVER['PHP_AUTH_USER'] == 'your_username' && $_SERVER['PHP_AUTH_PW'] == 'your_password'))
{
    header('WWW-Authenticate: Basic realm="Go away"');
    header('Status: 401 Unauthorized');
}
    else
{
    echo 'hello world';
}
 
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Is there a way to have a login authorisation via IIS 7?

Post by Doug G »

You should check the godaddy help and faq's for anything specific to godaddy hosting.

Usually you use windows file permissions to control access to sections of a website. If you remove permissions for the user account that IIS uses to handle anonymous web users from a directory or file, IIS will prompt for windows authentication to access the resource. This has the advantage of restricting access to any non-web files in the directory too, so a user can't browse directly to a jpeg, for example.
Post Reply