Home > Archive > PHP Language > January 2008 > Active directory and PHP
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Active directory and PHP
|
|
| mlimacarlos@gmail.com 2008-01-28, 7:10 pm |
| Is there anyway to work PHP with Active directory? My intention
consist in developing an application that authenticates automatically
PHP on W2k3 server.
tks,
Marcos
| |
| Ivan Marsh 2008-01-28, 7:10 pm |
| On Mon, 28 Jan 2008 10:01:22 -0800, mlimacarlos@gmail.com wrote:
> Is there anyway to work PHP with Active directory? My intention consist
> in developing an application that authenticates automatically PHP on
> W2k3 server.
> tks,
> Marcos
Certainly.
You can use LDAP directly from PHP or you can set up the webserver itself
to authenticate to AD through LDAP.
Not sure if you're talking about 2000 or 2003... afaik 2003 Active
Directory uses kerberos so that may be a more difficult cat to skin.
--
I told you this was going to happen.
| |
| ZeldorBlat 2008-01-28, 7:10 pm |
| On Jan 28, 1:01 pm, "mlimacar...@gmail.com" <mlimacar...@gmail.com>
wrote:
> Is there anyway to work PHP with Active directory? My intention
> consist in developing an application that authenticates automatically
> PHP on W2k3 server.
> tks,
> Marcos
Here's how I usually do it. Requires the PHP LDAP extension:
$domain_controller = 'mydc';
$domain = 'foo.local';
if(empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW']))
{
header('WWW-Authenticate: Basic realm="' . $domain . '"');
header('HTTP/1.0 401 Unauthorized');
die(); //if they hit cancel
}
if(($ldap = @ldap_connect($domain_controller, 389)) !== false) {
if(@ldap_bind($ldap, $_SERVER['PHP_AUTH_USER'] . '@' . $domain,
$_SERVER['PHP_AUTH_PW']) !== false) {
//Their credentials were valid, so do whatever you need to do
}
else {
//Their credentials weren't valid
header('WWW-Authenticate: Basic realm="' . $domain . '"');
header('HTTP/1.0 401 Unauthorized');
die(); //if they hit cancel
}
}
| |
| mlimacarlos@gmail.com 2008-01-28, 7:10 pm |
| Tks,
It was this that I needed.
On Jan 28, 5:08 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
> On Jan 28, 1:01 pm, "mlimacar...@gmail.com" <mlimacar...@gmail.com>
> wrote:
>
>
|
|
|
|
|