mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Fixed the login of new user from ldap in metaconsole. TICKET: #3118
(cherry picked from commit 7892d6bcb8bc03c451cbcea6f21e4cf2db4fa22b) Conflicts: pandora_console/include/auth/mysql.php
This commit is contained in:
parent
86b8831982
commit
a7f2765d3e
@ -172,7 +172,9 @@ function process_user_login_local ($login, $pass, $api = false) {
|
|||||||
|
|
||||||
function process_user_login_remote ($login, $pass, $api = false) {
|
function process_user_login_remote ($login, $pass, $api = false) {
|
||||||
global $config, $mysql_cache;
|
global $config, $mysql_cache;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Remote authentication
|
// Remote authentication
|
||||||
switch ($config["auth"]) {
|
switch ($config["auth"]) {
|
||||||
// LDAP
|
// LDAP
|
||||||
@ -225,21 +227,26 @@ function process_user_login_remote ($login, $pass, $api = false) {
|
|||||||
|
|
||||||
// Authentication ok, check if the user exists in the local database
|
// Authentication ok, check if the user exists in the local database
|
||||||
if (is_user ($login)) {
|
if (is_user ($login)) {
|
||||||
|
|
||||||
|
|
||||||
if (!user_can_login($login)) {
|
if (!user_can_login($login)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($config["auth"] === 'ad') && (isset($config['ad_advanced_config']) && $config['ad_advanced_config'])){
|
if (($config["auth"] === 'ad') &&
|
||||||
|
(isset($config['ad_advanced_config']) && $config['ad_advanced_config'])) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$return = enterprise_hook ('prepare_permissions_groups_of_user_ad',
|
$return = enterprise_hook ('prepare_permissions_groups_of_user_ad',
|
||||||
array ($login, $pass, false, true));
|
array ($login, $pass, false, true));
|
||||||
|
|
||||||
if ($return === "error_permissions") {
|
if ($return === "error_permissions") {
|
||||||
$config["auth_error"] = __("Problems with configuration
|
$config["auth_error"] =
|
||||||
permissions. Please contact with Administrator");
|
__("Problems with configuration permissions. Please contact with Administrator");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if ($return === "permissions_changed") {
|
if ($return === "permissions_changed") {
|
||||||
$config["auth_error"] = __("Your permmission have been change. Please, login again");
|
$config["auth_error"] = __("Your permmission have been change. Please, login again");
|
||||||
return false;
|
return false;
|
||||||
@ -250,6 +257,8 @@ function process_user_login_remote ($login, $pass, $api = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The user does not exist and can not be created
|
// The user does not exist and can not be created
|
||||||
if ($config['autocreate_remote_users'] == 0 || is_user_blacklisted ($login)) {
|
if ($config['autocreate_remote_users'] == 0 || is_user_blacklisted ($login)) {
|
||||||
$config["auth_error"] = __("Ooops User not found in
|
$config["auth_error"] = __("Ooops User not found in
|
||||||
@ -258,12 +267,35 @@ function process_user_login_remote ($login, $pass, $api = false) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the user in the local database
|
||||||
if (isset($config['ad_advanced_config']) && $config['ad_advanced_config']) {
|
if (isset($config['ad_advanced_config']) && $config['ad_advanced_config']) {
|
||||||
// Create the user in the local database enterprise_hook ('prepare_permissions_groups_of_user_ad', array ($login, $pass))
|
|
||||||
|
|
||||||
|
if ( defined('METACONSOLE') ) {
|
||||||
|
enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
enterprise_include_once ('meta/include/functions_groups_meta.php');
|
||||||
|
|
||||||
|
$return = groups_meta_synchronizing();
|
||||||
|
|
||||||
|
if ($return["group_create_err"] > 0 || $return["group_update_err"] > 0) {
|
||||||
|
$config["auth_error"] = __('Fail the group synchronizing');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = meta_tags_synchronizing();
|
||||||
|
if ($return['tag_create_err'] > 0 || $return['tag_update_err'] > 0) {
|
||||||
|
$config["auth_error"] = __('Fail the tag synchronizing');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the user
|
||||||
if (enterprise_hook ('prepare_permissions_groups_of_user_ad',
|
if (enterprise_hook ('prepare_permissions_groups_of_user_ad',
|
||||||
array ($login, $pass, array ('fullname' => $login,
|
array($login,
|
||||||
'comments' => 'Imported from ' .
|
$pass,
|
||||||
$config['auth']))) === false) {
|
array ('fullname' => $login,
|
||||||
|
'comments' => 'Imported from ' . $config['auth']),
|
||||||
|
false, defined('METACONSOLE'))) === false) {
|
||||||
|
|
||||||
$config["auth_error"] = __("User not found in database
|
$config["auth_error"] = __("User not found in database
|
||||||
or incorrect password");
|
or incorrect password");
|
||||||
@ -280,13 +312,16 @@ function process_user_login_remote ($login, $pass, $api = false) {
|
|||||||
$config["auth_error"] = __("User not found in database or incorrect password");
|
$config["auth_error"] = __("User not found in database or incorrect password");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Check the creation in the nodes
|
||||||
|
|
||||||
profile_create_user_profile ($login, $config['default_remote_profile'],
|
profile_create_user_profile ($login, $config['default_remote_profile'],
|
||||||
$config['default_remote_group'], false, $config['default_assign_tags']);
|
$config['default_remote_group'], false, $config['default_assign_tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $login;
|
return $login;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a user is administrator.
|
* Checks if a user is administrator.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
* @package Include
|
* @package Include
|
||||||
* @subpackage Profile_Functions
|
* @subpackage Profile_Functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function profile_exist($name) {
|
||||||
|
return (bool)db_get_value('id_perfil', 'tperfil', 'name', $name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get profile name from id.
|
* Get profile name from id.
|
||||||
@ -67,7 +71,9 @@ function profile_get_profiles ($filter = false) {
|
|||||||
*
|
*
|
||||||
* @return mixed Number id if succesful, false if not
|
* @return mixed Number id if succesful, false if not
|
||||||
*/
|
*/
|
||||||
function profile_create_user_profile ($id_user, $id_profile = 1, $id_group = 0, $assignUser = false, $tags = '') {
|
function profile_create_user_profile ($id_user,
|
||||||
|
$id_profile = 1, $id_group = 0, $assignUser = false, $tags = '') {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (empty ($id_profile) || $id_group < 0)
|
if (empty ($id_profile) || $id_group < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user