-
July 13th, 2004, 01:51 AM
#1
Member
PHP authentication against a NT4.0 Server
Hey Guys,
I am starting work at my old highschool and one of my main projects at the moment is developing the school's intranet.
The school has 550 students and i want to use authentication against the NT server, as MySQL wouldnt be as practical to use as straight out authentication against the database.
I was wondering if anyone has code or has a resourse to point me to, for this.
If you guys need more information, just post it.
Thanks,
-
July 15th, 2004, 04:55 PM
#2
There are scripts on how to use authentication with PHP, here is a simple example:
Code:
<?php
//sample login **** using sessions
$mysql_host = "localhost";
$mysql_user = "user";
$mysql_pass = "passwd";
$mysql_db = "auth";
$mysql_table = "user";
//connect to the database....
$connection =mysql_connect ("$mysql_host","$mysql_user","$mysql_pass")
or die ("I cannot connect to the database... arrgh!");
//select the database ****
$database = mysql_select_db("$mysql_db")
or die ("I cannot select a database!!! arrgh!");
$mysql = "SELECT * FROM $mysql_table";
$results = mysql_query("$mysql");
while($**** = mysql_fetch_array($results))
{
$user=$****[user];
$password=$****[pass];
}
if (!isset($_SERVER['PHP_AUTH_USER']))
{
header('WWW-Authenticate: Some ****="My ****"');
header('HTTP/1.0 401 Unauthorized');
//print some **** if somebosy failed to log in
echo 'You have entered thew wrong password. heh';
exit;
}
else
{
if($_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $password)
{
//logged in!! w00t
echo "Logged in!!";
}
else
{
echo "Huh? I could not log you in";
exit;
}
}
?>
Then make a database table PHP_AUTH_USER.
Hope this helps.
-
July 19th, 2004, 02:14 PM
#3
I think you're looking for something that can do NTLM authentication.
If so, take a look at mod_ntlm.
Oliver's Law:
Experience is something you don't get until just after you need it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|