phpDocumentor VFront
Authentication
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file auth.ldap.php

Documentation is available at auth.ldap.php

  1. <?php
  2. /**
  3.  * @package VFront
  4.  * @subpackage Authentication
  5.  * @author Mario Marcello Verona <marcelloverona@gmail.com>
  6.  * @copyright 2007 Mario Marcello Verona
  7.  * @version 0.90
  8.  * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  9.  * @see auth
  10.  * 
  11.  */
  12.  
  13.  
  14.  
  15.  
  16.     /**
  17.      * Sistema di autenticazione attraverso LDAP
  18.      * Funzione richiamata dalla classe {@link auth}
  19.      *
  20.      * @param string $sn SN (email) per LDAP
  21.      * @param string $password Password
  22.      * @return mixed 
  23.      */
  24.     function auth_ldap($sn,$password){
  25.         
  26.         global $conf_auth;
  27.         
  28.         $ds=ldap_connect($conf_auth['ldap']['host']or die(openErrorGenerico("Impossibile collegarsi al server LDAP",true));   // must be a valid LDAP server!
  29.         
  30.         
  31.         if ($ds)
  32.             
  33.              // binding to ldap server
  34.              $ldapbind ldap_bind($ds)//, "cn=$sn, ".$conf_auth['ldap']['base_dn'], $password);
  35.              
  36.              // Search surname entry
  37.              $filter="(&({$conf_auth['campo_email']}=$sn)({$conf_auth['campo_password']}=$password))";
  38.             
  39.             
  40.              if(!$ldapbindreturn array('response'=>false);
  41.         
  42.             
  43.             $sr=@ldap_search($ds$conf_auth['ldap']['base_dn']$filteror die(openErrorGenerico("Impossibile collegarsi al server LDAP"));  
  44.         
  45.             $n_trovati=ldap_count_entries($ds$sr);
  46.             
  47.             if($n_trovati==0){
  48.                 
  49.                 return array('response'=>false);
  50.             }
  51.             
  52.             
  53.             $info ldap_get_entries($ds$sr);
  54.    
  55. //            print_r($info[0]);
  56.             
  57.             foreach($info[0as $k=>$val){
  58.                 
  59.                 $RS[$k]=$val[0];
  60.             }
  61.         
  62.             //    Closing connection
  63.             ldap_close($ds);
  64.             
  65.             return array('response'=>true,$RS);
  66.         
  67.         else {
  68.             
  69.             openErrorGenerico("Impossibile connettersi a LDAP",true);
  70.         }
  71.     
  72.     }
  73.  
  74.  
  75.  
  76.  
  77. ?>

Documentation generated on Sat, 22 Sep 2007 11:49:49 +0200 by phpDocumentor 1.4.0a2