Here is how i implement it
This works well with OpenLAP and Open Directory (Apple Implementation based on OpenLDAP):
Download adLDAP from sourceforge (Tested with 3.3.2): (http://prdownloads.sourceforge.net/adldap/adLDAP_3.3.2.zip?download)
At the top of class.staff.php
include("adLDAP/adLDAP.php");
Search for function check_passwd
Replace the Function with this:
/*compares user password*/
function check_passwd($password){
// Change made for LDAP Auth
// Joerg Hochwald <http://www.bewoelkt.net>
//return (strlen($this->passwd) && strcmp($this->passwd, MD5($password))==0)?(TRUE):(FALSE);
<STRONG><s>**</s>return (strlen($this->passwd) && strcmp($this->username,$password))?(TRUE):(FALSE);<e>**</e></STRONG>
// Change this line to the FQDN of your LDAP Server
$ds=ldap_connect('ldap://<STRONG><s>**</s>YOURLDAPSERVER<e>**</e></STRONG>) or die("Couldn't connect to LDAP!");
// Change this line to the name of your LDAP Tree
$domain="uid=".$this->username.",<STRONG><s>**</s>cn=users,dc=admins,dc=bewoelkt,dc=net<e>**</e></STRONG>";
if (!@ldap_bind( $ds, $domain, $password) ) {
// Auth failed!
return(FALSE);
}
else{
// Auth succeeded!
return(TRUE);
}
// End Changes
}
You have to create a user in OST with excatly the same login as the login in your LDAP Directory! Give him a dummy password!
There a a few stange things: The user has to login with the Dummy password an change it to whatever he like.
After that he is able to login with the password from LDAP and the local one in OST.
And a hint about security:
If your LDAP Server and OST are not in a private network (behind a firewall?) you shoul use Secured LDAP (aka LDAPS)!
And last but not least: If your Directory need a bind to connect, you have to change the code above. Read the adLDAP for further infos about binding ;-)