|
|
|
@ -1,9 +1,10 @@ |
|
|
|
|
<?php // External login module : LDAP
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
// External login module : LDAP |
|
|
|
|
/** |
|
|
|
|
* This files is included by newUser.ldap.php and login.ldap.php |
|
|
|
|
* It implements the functions nedded by both files |
|
|
|
|
* */ |
|
|
|
|
|
|
|
|
|
//Includes the configuration file |
|
|
|
|
require_once dirname(__FILE__) . '/../../inc/global.inc.php'; |
|
|
|
|
require_once dirname(__FILE__) . '/../../inc/conf/auth.conf.php'; |
|
|
|
@ -19,8 +20,7 @@ function extldap_purify_string($string) { |
|
|
|
|
global $extldap_config; |
|
|
|
|
if (isset($extldap_config['encoding'])) { |
|
|
|
|
return trim(api_to_system_encoding($string, $extldap_config['encoding'])); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
return trim($string); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -31,8 +31,7 @@ function extldap_purify_string($string) { |
|
|
|
|
* @return resource ldap link identifier or false |
|
|
|
|
* @author ndiechburg <noel@cblue.be> |
|
|
|
|
* */ |
|
|
|
|
function extldap_connect() |
|
|
|
|
{ |
|
|
|
|
function extldap_connect() { |
|
|
|
|
global $extldap_config; |
|
|
|
|
|
|
|
|
|
if (!is_array($extldap_config['host'])) |
|
|
|
@ -81,8 +80,7 @@ function extldap_connect() |
|
|
|
|
* Add possibility to get user info from LDAP without check password (if CAS auth and LDAP profil update) |
|
|
|
|
* |
|
|
|
|
* */ |
|
|
|
|
function extldap_authenticate($username, $password, $in_auth_with_no_password=false) |
|
|
|
|
{ |
|
|
|
|
function extldap_authenticate($username, $password, $in_auth_with_no_password = false) { |
|
|
|
|
global $extldap_config; |
|
|
|
|
|
|
|
|
|
if (empty($username) or empty($password)) { |
|
|
|
@ -128,8 +126,7 @@ function extldap_authenticate($username, $password, $in_auth_with_no_password=fa |
|
|
|
|
$ubind = @ldap_bind($ds, $user['dn'], $password); |
|
|
|
|
if ($ubind !== false) { |
|
|
|
|
return $user; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
error_log('EXTLDAP : Wrong password for ' . $user['dn']); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -144,8 +141,7 @@ function extldap_authenticate($username, $password, $in_auth_with_no_password=fa |
|
|
|
|
* @return array userinfo array |
|
|
|
|
* @author ndiechburg <noel@cblue.be> |
|
|
|
|
* */ |
|
|
|
|
function extldap_get_chamilo_user($ldap_user, $cor = null) |
|
|
|
|
{ |
|
|
|
|
function extldap_get_chamilo_user($ldap_user, $cor = null) { |
|
|
|
|
global $extldap_user_correspondance; |
|
|
|
|
if (is_null($cor)) { |
|
|
|
|
$cor = $extldap_user_correspondance; |
|
|
|
@ -177,7 +173,6 @@ function extldap_get_chamilo_user($ldap_user, $cor = null) |
|
|
|
|
$chamilo_user[$chamilo_field] = extldap_purify_string($ldap_user[$ldap_field][0]); |
|
|
|
|
} else { |
|
|
|
|
error_log('EXTLDAP WARNING : ' . $ldap_field . '[0] field is not set in ldap array'); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -185,13 +180,12 @@ function extldap_get_chamilo_user($ldap_user, $cor = null) |
|
|
|
|
return $chamilo_user; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Please declare here all the function you use in extldap_user_correspondance |
|
|
|
|
* All these functions must have an $ldap_user parameter. This parameter is the |
|
|
|
|
* array returned by the ldap for the user |
|
|
|
|
* */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* example function for email |
|
|
|
|
* */ |
|
|
|
@ -203,11 +197,11 @@ function extldap_get_email($ldap_user){ |
|
|
|
|
function extldap_get_status($ldap_user) { |
|
|
|
|
return STUDENT; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function extldap_get_admin($ldap_user) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* return the string used to search a user in ldap |
|
|
|
|
* |
|
|
|
|