
January 30th, 2004, 01:44 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 17
Time spent in forums: 15 m 37 sec
Reputation Power: 0
|
|
|
PHP LDAP Userlogin
Hi All,
I am Using OpenLDAP .. they already got user and password(ldif files) in the System.
the only think when user logged in i need to check that username and password in LDAP Server. i need the code how to do it..
I am using PHP
$ldap=ldap_connect("localhost") or die("no connection for LDAP");
$password=crypt($password);
if($ldap){
$bind_results=ldap_bind($ldap,"uid=" . $username . ", ou=staff,o=name.com", $password) or die("no user");
$dn = "ou=staff,o=name.com";
$filter = "(|(uid=" . $username . "*))";
$nds_stuff=array("cn","Manager");
$results=ldap_search($ldap, $dn, $filter, $nds_stuff);
$info=ldap_get_entries($ldap,$results);
if($info["count"] != 0){
header("Location: /index.php");
}
else{
header("Location:../login.php");
}
ldap_close($ldap);
}
else{
die("no connection for LDAP");
}
|