Re: Pass Windows credentials
- From: ZeldorBlat <zeldorblat@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 11:07:23 -0700
On Oct 31, 1:44 pm, simone.na...@xxxxxxxxxxxx (Simone Nanni) wrote:
Hi everybody,
i'm trying to do an hard stuff.....
I want to create a PHP page where users can authenticate themselves passing their Windows (XP or 2000) logon credentials trasparently.
So, if i've made logon on my workstation with "username" and "password" i want to catch them and reuse to give them access.
This stuff will run on a Linux Slackware box with Apache 2.2.4 - PHP 5.2.4 and Samba 3.0.26a
Somebody can help me?!
Thanx a lot!
Simone Nanni
ICT Technician
A.O.U. Policlinico Tor Vergata
Viale Oxford, 81
00133 - Roma - RM - Italy
Here's how you get it (change "domain_name" to whatever your Windows
domain is):
if(empty($_SERVER['PHP_AUTH_USER']) ||
empty($_SERVER['PHP_AUTH_PW']) ) {
header('WWW-Authenticate: Basic realm="domain_name"');
header('HTTP/1.0 401 Unauthorized');
die(); //if they hit cancel
}
Now $_SERVER['PHP_AUTH_USER'] will have the username and
$_SERVER['PHP_AUTH_PW'] will have the password.
If you want to check that against your domain controller you can do
this (change "domain_controller" and "domain_name" to whatever they
are):
if(($ldap = @ldap_connect('domain_controller', 389)) !== false) {
if(@ldap_bind($ldap, $_SERVER['PHP_AUTH_USER'] . '@domain_name',
$_SERVER['PHP_AUTH_PW']) !== false) {
//The username and password are legit
}
else {
//The username and password are bogus
header('WWW-Authenticate: Basic realm="domain_name"');
header('HTTP/1.0 401 Unauthorized');
die(); //if they hit cancel
}
}
.
- References:
- Pass Windows credentials
- From: Simone Nanni
- Pass Windows credentials
- Prev by Date: Re: [PHP] Pass Windows credentials
- Next by Date: Re: [PHP] APACHE MOD_REWRITE
- Previous by thread: Re: [PHP] Pass Windows credentials
- Index(es):
Relevant Pages
|