Authentification Help
| From: | Mike Tuller | Date: | Thu, 08 Jul 2004 18:19:55 +0000 |
| Subject: | Authentification Help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-189990@lists.php.net to get a copy of this message | ||
I have created a script that authenticates to an Active Directory server. This script works when I try to login, but the problem is that I have to bind to be able to get "my" dn to be able to authenticate, but I need authenticate first to be able to get "my" dn. Chicken before the egg problem.
In the ldap_bind(), I have entered "my" dn to be able to authenticate for now, but with this I am the only person that would be able to login.
I could bind to the server twice, once to get an individuals "dn" , set the variable, and then once I have the "user's" dn I could bind again as that user, but this seems like it would cause a lot of overhead. Does anyone have a better way to do this than bind twice?
$dn = "OU=Anoka-Hennepin,DC=ah,DC=isd11";
$filter = "(samaccountname=" . $username . "*)";
$ad = ldap_connect("ldap://172.22.1.20")
or die("Couldn't connect to AD!");
$bd = ldap_bind($ad, "CN=Tuller\, Mike,OU=Staff,OU=LCDC,OU=Anoka-Hennepin,DC=ah,DC=isd11",$password)
or die("Couldn't bind to AD!");
$result = ldap_search($ad, $dn, $filter);
$entries = ldap_get_entries($ad, $result);
for ($i=0; $i<$entries["count"]; $i++)
{
echo $entries[$i]["dn"];
}