Re: Pass Windows credentials



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
}
}

.



Relevant Pages

  • Re: Get Windows login
    ... I was given a task to develop a php based application. ... available on Windows platform. ... //They haven't given us a username and password yet ... die; //if they hit cancel ...
    (comp.lang.php)
  • Re: What is the maximal length of usernames on Solaris?
    ... > system to accommodate 4096 character user ID's. ... > 8 characters is to short in many circumstances. ... >>People who whine about petty shit such as how long a username can be ... but Windows uses a backward slash. ...
    (comp.sys.sun.admin)
  • RE: Adding a virtual FTP folder to IIS
    ... I think we can follow the Form Authentication modal. ... application will use the ASPNET account. ... If we change the username ... Windows identity different from that of the default process identity. ...
    (microsoft.public.dotnet.framework)
  • Re: Network shares and printing
    ... Windows cannot obtain the domain controller name for your computer network. ... shared drive and entering proper username and password. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Locked out of my computer - please help
    ... > the bottom of the screen to use a Workgroup name. ... > says that either my username or password is incorrect. ... > latest Windows settings that worked. ... > I still do not have a recent backup. ...
    (microsoft.public.windowsxp.security_admin)