diff --git a/src/etc/inc/auth.inc b/src/etc/inc/auth.inc index 46bd9a78a..b6ad93ea3 100644 --- a/src/etc/inc/auth.inc +++ b/src/etc/inc/auth.inc @@ -723,16 +723,6 @@ function auth_get_authserver($name) foreach ($config['system']['authserver'] as $authcfg) { if ($authcfg['name'] == $name) { if ($authcfg['type'] == 'ldap' || $authcfg['type'] == 'ldap-totp') { - // let's try to avoid regenerating the ldap url in every function. - if (strstr($authcfg['ldap_urltype'], "Standard")) { - $authcfg['ldap_full_url'] = "ldap://"; - } else { - $authcfg['ldap_full_url'] = "ldaps://"; - } - $authcfg['ldap_full_url'] .= is_ipaddrv6($authcfg['host']) ? "[{$authcfg['host']}]" : $authcfg['host']; - if (!empty($authcfg['ldap_port'])) { - $authcfg['ldap_full_url'] .= ":{$authcfg['ldap_port']}"; - } // make sure a user and password entry exists and are null for anonymous usage if (empty($authcfg['ldap_binddn'])) { $authcfg['ldap_binddn'] = null; diff --git a/src/www/system_usermanager_import_ldap.php b/src/www/system_usermanager_import_ldap.php index 234be6f25..43bb93605 100644 --- a/src/www/system_usermanager_import_ldap.php +++ b/src/www/system_usermanager_import_ldap.php @@ -72,6 +72,15 @@ foreach ($servers as $server) { if ($authcfg['type'] == 'ldap' || $authcfg['type'] == 'ldap-totp') { $authName = $server; $ldap_server = $authcfg; + if (strstr($ldap_server['ldap_urltype'], "Standard") || strstr($ldap_server['ldap_urltype'], "StartTLS")) { + $ldap_server['ldap_full_url'] = "ldap://"; + } else { + $ldap_server['ldap_full_url'] = "ldaps://"; + } + $ldap_server['ldap_full_url'] .= is_ipaddrv6($authcfg['host']) ? "[{$authcfg['host']}]" : $authcfg['host']; + if (!empty($ldap_server['ldap_port'])) { + $ldap_server['ldap_full_url'] .= ":{$authcfg['ldap_port']}"; + } break; } }