LDAP/StartTLS userimport, start using correct url and move logic to legacy page. for https://github.com/opnsense/core/issues/3445

This commit is contained in:
Ad Schellevis 2019-10-09 17:52:21 +02:00
parent ec613d3042
commit c4fba1c62e
2 changed files with 9 additions and 10 deletions

View File

@ -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;

View File

@ -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;
}
}