Location: PHPKode > projects > IntraMessenger > common/extern/ldap.auth.inc.php
<?php
/*******************************************************
 **                  IntraMessenger - server          **
 **                                                   **
 **  Copyright:      (C) 2006 - 2010 THeUDS           **
 **  Web:            http://www.theuds.com            **
 **                  http://www.intramessenger.net    **
 **  Licence :       GPL (GNU Public License)         **
 **  http://opensource.org/licenses/gpl-license.php   **
 *******************************************************/

/*******************************************************
 **       This file is part of IntraMessenger-server  **
 **                                                   **
 **  IntraMessenger is a free software.               **
 **  IntraMessenger is distributed in the hope that   **
 **  it will be useful, but WITHOUT ANY WARRANTY.     **
 *******************************************************/

define("_EXTERNAL_AUTHENTICATION_NAME", "LDAP");

function f_external_authentication($t_user, $t_pass)
{
  $t_verif_pass = "Ko";
  //
  if (extension_loaded('ldap'))
  {
    require("../common/config/ldap.config.inc.php");
    if ( ($ldap_host != '') and ($ldap_basedn != '') )
    {
      if (intval($ldap_port > 0))
        $ldapconn = ldap_connect($ldap_host, $ldap_port);
      else
        $ldapconn = ldap_connect($ldap_host);
      //
      if ($ldapconn) 
      {
        $ldapbind = ldap_bind($ldapconn, "cn=" . $t_user . ", " . $ldap_basedn, $t_pass);
        if ($ldapbind) $t_verif_pass = "OK";
        ldap_close($ldapconn);
      }
      else
        die("Could not connect to LDAP server");   // Connexion au serveur LDAP impossible
    }
  }
  //
  return $t_verif_pass;
}
?>
Return current item: IntraMessenger