Source for file auth.ldap.php
Documentation is available at auth.ldap.php
* @subpackage Authentication
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007 Mario Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
* Sistema di autenticazione attraverso LDAP
* Funzione richiamata dalla classe {@link auth}
* @param string $sn SN (email) per LDAP
* @param string $password Password
$ds= ldap_connect($conf_auth['ldap']['host']) or die(openErrorGenerico("Impossibile collegarsi al server LDAP",true)); // must be a valid LDAP server!
// binding to ldap server
$ldapbind = ldap_bind($ds); //, "cn=$sn, ".$conf_auth['ldap']['base_dn'], $password);
$filter= "(&({$conf_auth['campo_email']}=$sn)({$conf_auth['campo_password']}=$password))";
if(!$ldapbind) return array('response'=> false);
$sr= @ldap_search($ds, $conf_auth['ldap']['base_dn'], $filter) or die(openErrorGenerico("Impossibile collegarsi al server LDAP"));
$n_trovati= ldap_count_entries($ds, $sr);
return array('response'=> false);
$info = ldap_get_entries($ds, $sr);
foreach($info[0] as $k=> $val){
return array('response'=> true,$RS);
|