Merge branch 'ent-10254-15114-anadir-timeout-y-secondary-server-a-ad' into 'develop'

Ent 10254 [#15114]Añadir timeout y secondary server a AD

See merge request artica/pandorafms!6091
This commit is contained in:
Rafael Ameijeiras 2023-07-18 10:14:29 +00:00
commit 06d3664b2f
4 changed files with 47 additions and 5 deletions

View File

@ -210,7 +210,7 @@ if (is_ajax() === true) {
// Ldapsearch timeout.
// Default Ldapsearch timeout.
set_when_empty($config['ldap_searh_timeout'], 5);
set_when_empty($config['ldap_search_timeout'], 5);
$row = [];
$row['name'] = __('Ldap search timeout (secs)');
$row['control'] = html_print_input_text(
@ -558,7 +558,13 @@ echo '</form>';
if ($('input[type=checkbox][name=secondary_ldap_enabled]:checked').val() == 1) {
$("tr[id*='ldap_'][id$='_secondary']").show();
} else {
$( "tr[id*='ldap_'][id$='_secondary']" ).hide();
$( "tr[id*='ldap_'][id$='_secondary']" ).hide();
}
if ($('input[type=checkbox][name=secondary_active_directory]:checked').val() == 1) {
$("tr[id*='ad_'][id$='_secondary']").show();
} else {
$( "tr[id*='ad_'][id$='_secondary']" ).hide();
}
}
$( document ).ready(function() {

View File

@ -237,8 +237,13 @@ function process_user_login_remote($login, $pass, $api=false)
// Active Directory.
case 'ad':
if (enterprise_hook('ad_process_user_login', [$login, $pass]) === false) {
$config['auth_error'] = 'User not found in database or incorrect password';
$sr = enterprise_hook('ad_process_user_login', [$login, $pass]);
// Try with secondary server.
if ($sr === false && (bool) $config['secondary_active_directory'] === true) {
$sr = enterprise_hook('ad_process_user_login', [$login, $pass, true]);
}
if ($sr === false) {
return false;
}
break;

View File

@ -627,6 +627,30 @@ function config_update_config()
$error_update[] = __('Domain');
}
if (config_update_value('secondary_active_directory', get_parameter('secondary_active_directory'), true) === false) {
$error_update[] = __('Secondary active directory');
}
if (config_update_value('ad_server_secondary', get_parameter('ad_server_secondary'), true) === false) {
$error_update[] = __('Secondary active directory server');
}
if (config_update_value('ad_port_secondary', get_parameter('ad_port_secondary'), true) === false) {
$error_update[] = __('Secondary active directory port');
}
if (config_update_value('ad_start_tls_secondary', get_parameter('ad_start_tls_secondary'), true) === false) {
$error_update[] = __('Secondary start TLS');
}
if (config_update_value('ad_search_timeout', get_parameter('ad_search_timeout'), true) === false) {
$error_update[] = __('AD search timeout');
}
if (config_update_value('ad_domain_secondary', get_parameter('ad_domain_secondary'), true) === false) {
$error_update[] = __('Secondary domain');
}
if (config_update_value('ad_adv_perms', get_parameter('ad_adv_perms'), true) === false) {
$error_update[] = __('Advanced Permisions AD');
}
@ -3100,6 +3124,14 @@ function config_process_config()
config_update_value('ad_port', 389);
}
if (!isset($config['ad_server_secondary'])) {
config_update_value('ad_server_secondary', 'localhost');
}
if (!isset($config['ad_port_secondary'])) {
config_update_value('ad_port_secondary', 389);
}
if (!isset($config['ad_start_tls'])) {
config_update_value('ad_start_tls', 0);
}

View File

@ -712,7 +712,6 @@ if (isset($config['id_user']) === false) {
login_check_failed($nick);
}
$config['auth_error'] = __('User is blocked');
$login_failed = true;
}