windows 2000 authentication with IIS and php 4.3

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skatestreet540
Forum Newbie
Posts: 4
Joined: Thu Feb 13, 2003 3:54 pm
Contact:

windows 2000 authentication with IIS and php 4.3

Post by skatestreet540 »

I need a script that will allow me to authenticate against a windows 2000 domain server. All I need to know if the user name and password is correct. I also have a website that authenticate against my own database for priviledges. I need to know if the person logining in is who they claim to be. Then log them into my own database for priviledges. I am on a windows 2000 box with IIS. Running php 4.3. Does anyone have any ideas. Here is an example that used to work on prev versions of php.

//Copyright 2002 Scott Dial
//scott@scottdial.com
//
//This code is free to modify, use, abuse, or whatever you like. It'd be interesting though to hear what you are using it for, so shoot me an email if you use this snippet.

//These values are pulled straight from winbase.h from the platform sdk

define("LOGON32_LOGON_INTERACTIVE", 2);
define("LOGON32_LOGON_NETWORK", 3);
define("LOGON32_LOGON_BATCH", 4);
define("LOGON32_LOGON_SERVICE", 5);

define("LOGON32_PROVIDER_DEFAULT", 0);
define("LOGON32_PROVIDER_WINNT35", 1);
define("LOGON32_PROVIDER_WINNT40", 2);
define("LOGON32_PROVIDER_WINNT50", 3);

//These aren't actually in winbase.h but are accurate
define("LOGON32_DOMAIN_LOCAL", ".");
define("LOGON32_DOMAIN_ALL", 0);


function NT_Validate_User($user, $domain, $pass)
{
w32api_register_function("kernel32.dll", "LocalAlloc", "long");
w32api_register_function("kernel32.dll", "LocalFree", "long");
w32api_register_function("kernel32.dll", "CloseHandle", "bool");
w32api_register_function("advapi32.dll", "LogonUserA", "bool");

$cleanup = w32api_register_function("deref.dll", "deref", "long");

$pHandle = LocalAlloc(0, 4); //Pointer to a HANDLE

$test = LogonUserA($user,
$domain,
$pass,
LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT,
$pHandle);

if($test != 0)
{
return 1;
if($cleanup)
{
$handle = deref($pHandle);
CloseHandle($handle);
}
LocalFree($pHandle);
} else {
return 0;
}
}
skatestreet540
Forum Newbie
Posts: 4
Joined: Thu Feb 13, 2003 3:54 pm
Contact:

yes

Post by skatestreet540 »

yes just use get_current_user and it works with what i want to know
Post Reply