From 24c0c8c12bba2aa465736a8606cfc5d8e0d57e8b Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 17 Jan 2017 15:09:23 +0100 Subject: [PATCH] Add select profile, group and tags when autocreate user in few options. And add metaconsole replication users in node --- pandora_console/godmode/setup/setup_auth.php | 4 +++ pandora_console/include/auth/mysql.php | 36 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 41afac34e6..0444731007 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -58,6 +58,10 @@ if (is_ajax ()) { $row['control'] = __('Yes').' '.html_print_radio_button_extended('autocreate_remote_users', 1, '', $config['autocreate_remote_users'], false, '', '', true).'  '; $row['control'] .= __('No').' '.html_print_radio_button_extended('autocreate_remote_users', 0, '', $config['autocreate_remote_users'], false, '', '', true); $table->data['autocreate_remote_users'] = $row; + + if (enterprise_installed()) { + add_enterprise_auth_autocreate_profiles($table, $type_auth); + } } switch ($type_auth) { diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 296037be31..f5d5e98d8e 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -268,7 +268,7 @@ function process_user_login_remote ($login, $pass, $api = false) { return false; } - if (isset($config['ad_advanced_config']) && $config['ad_advanced_config']) { + if ($config["auth"] === 'ad' && (isset($config['ad_advanced_config']) && $config['ad_advanced_config'])) { if ( defined('METACONSOLE') ) { @@ -313,10 +313,40 @@ function process_user_login_remote ($login, $pass, $api = false) { return false; } - //TODO: Check the creation in the nodes - profile_create_user_profile ($login, $config['default_remote_profile'], $config['default_remote_group'], false, $config['default_assign_tags']); + //TODO: Check the creation in the nodes + if ( is_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; + } + + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR ) { + if (create_user ($login, $pass, + array ('fullname' => $login, + 'comments' => 'Imported from ' . $config['auth']) + ) === false) + continue; + profile_create_user_profile ($login, $config['default_remote_profile'], + $config['default_remote_group'], false, $config['default_assign_tags']); + } + metaconsole_restore_db(); + } + } } return $login;