"LDAP", 'radius' => "Radius", 'voucher' => "Voucher" ); if (!isset($config['system']['authserver'])) { $config['system']['authserver'] = array(); } if (empty($config['ca']) || !is_array($config['ca'])) { $config['ca'] = array(); } $a_servers = auth_get_authserver_list(); $a_server = array(); foreach ($a_servers as $servers) { $a_server[] = $servers; } $act = null; if ($_SERVER['REQUEST_METHOD'] === 'GET') { // input record id, if valid if (isset($_GET['id']) && isset($a_server[$_GET['id']])) { $id = $_GET['id']; } if (isset($_GET['act'])) { $act = $_GET['act']; } $pconfig = array(); if ($act == "new") { $pconfig['ldap_protver'] = 3; $pconfig['radius_srvcs'] = "both"; $pconfig['radius_auth_port'] = "1812"; $pconfig['radius_acct_port'] = "1813"; $pconfig['type'] = 'ldap'; } elseif ($act == "edit" && isset($id)) { $pconfig['type'] = $a_server[$id]['type']; $pconfig['name'] = $a_server[$id]['name']; if ($pconfig['type'] == "ldap") { $pconfig['ldap_caref'] = $a_server[$id]['ldap_caref']; $pconfig['ldap_host'] = $a_server[$id]['host']; $pconfig['ldap_port'] = $a_server[$id]['ldap_port']; $pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype']; $pconfig['ldap_protver'] = $a_server[$id]['ldap_protver']; $pconfig['ldap_scope'] = $a_server[$id]['ldap_scope']; $pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn']; $pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn']; $pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query']; $pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user']; if (!empty($a_server[$id]['ldap_binddn'])) { $pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn']; } if (!empty($a_server[$id]['ldap_bindpw'])) { $pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw']; } } elseif ($pconfig['type'] == "radius") { $pconfig['radius_host'] = $a_server[$id]['host']; $pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port']; $pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port']; $pconfig['radius_secret'] = $a_server[$id]['radius_secret']; $pconfig['radius_timeout'] = $a_server[$id]['radius_timeout']; if (!empty($pconfig['radius_auth_port']) && !empty($pconfig['radius_acct_port'])) { $pconfig['radius_srvcs'] = "both"; } else { $pconfig['radius_srvcs'] = "auth"; } if (empty($pconfig['radius_auth_port'])) { $pconfig['radius_auth_port'] = 1812; } } } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; if (isset($pconfig['id']) && isset($a_server[$pconfig['id']])) { $id = $pconfig['id']; } if (isset($pconfig['act'])) { $act = $pconfig['act']; } if (isset($pconfig['save'])) { /* input validation */ if ($pconfig['type'] == "ldap") { $reqdfields = explode(" ", "name type ldap_host ldap_port ". "ldap_urltype ldap_protver ldap_scope ". "ldap_attr_user ldapauthcontainers"); $reqdfieldsn = array( gettext("Descriptive name"), gettext("Type"), gettext("Hostname or IP"), gettext("Port value"), gettext("Transport"), gettext("Protocol version"), gettext("Search level"), gettext("User naming Attribute"), gettext("Authentication container")); if (!empty($pconfig['ldap_binddn']) && !empty($pconfig['ldap_bindpw'])) { $reqdfields[] = "ldap_binddn"; $reqdfields[] = "ldap_bindpw"; $reqdfieldsn[] = gettext("Bind user DN"); $reqdfieldsn[] = gettext("Bind Password"); } } if ($pconfig['type'] == "radius") { $reqdfields = explode(" ", "name type radius_host radius_srvcs"); $reqdfieldsn = array( gettext("Descriptive name"), gettext("Type"), gettext("Hostname or IP"), gettext("Services")); if ($pconfig['radisu_srvcs'] == "both" || $pconfig['radisu_srvcs'] == "auth") { $reqdfields[] = "radius_auth_port"; $reqdfieldsn[] = gettext("Authentication port value"); } if ($id == null) { $reqdfields[] = "radius_secret"; $reqdfieldsn[] = gettext("Shared Secret"); } } do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); if (!empty($pconfig['ldap_host']) && preg_match("/[^a-zA-Z0-9\.\-_]/", $pconfig['ldap_host'])) { $input_errors[] = gettext("The host name contains invalid characters."); } if (!empty($pconfig['radius_host']) && preg_match("/[^a-zA-Z0-9\.\-_]/", $pconfig['radius_host'])) { $input_errors[] = gettext("The host name contains invalid characters."); } if (auth_get_authserver($pconfig['name']) && !isset($id)) { $input_errors[] = gettext("An authentication server with the same name already exists."); } if (($pconfig['type'] == "radius") && isset($pconfig['radius_timeout']) && !empty($pconfig['radius_timeout']) && (!is_numeric($pconfig['radius_timeout']) || (is_numeric($pconfig['radius_timeout']) && ($pconfig['radius_timeout'] <= 0)))) { $input_errors[] = gettext("RADIUS Timeout value must be numeric and positive."); } if (count($input_errors) == 0) { $server = array(); $server['refid'] = uniqid(); if (isset($id)) { $server = $a_server[$id]; } else { $server['type'] = $pconfig['type']; $server['name'] = $pconfig['name']; } if ($server['type'] == "ldap") { if (!empty($pconfig['ldap_caref'])) { $server['ldap_caref'] = $pconfig['ldap_caref']; } $server['host'] = $pconfig['ldap_host']; $server['ldap_port'] = $pconfig['ldap_port']; $server['ldap_urltype'] = $pconfig['ldap_urltype']; $server['ldap_protver'] = $pconfig['ldap_protver']; $server['ldap_scope'] = $pconfig['ldap_scope']; $server['ldap_basedn'] = $pconfig['ldap_basedn']; $server['ldap_authcn'] = $pconfig['ldapauthcontainers']; $server['ldap_extended_query'] = $pconfig['ldap_extended_query']; $server['ldap_attr_user'] = $pconfig['ldap_attr_user']; if (!empty($pconfig['ldap_binddn']) && !empty($pconfig['ldap_bindpw']) ){ $server['ldap_binddn'] = $pconfig['ldap_binddn']; $server['ldap_bindpw'] = $pconfig['ldap_bindpw']; } else { if (isset($server['ldap_binddn'])) { unset($server['ldap_binddn']); } if (isset($server['ldap_bindpw'])) { unset($server['ldap_bindpw']); } } } elseif ($server['type'] == "radius") { $server['host'] = $pconfig['radius_host']; if (!empty($pconfig['radius_secret'])) { $server['radius_secret'] = $pconfig['radius_secret']; } if (!empty($pconfig['radius_timeout'])) { $server['radius_timeout'] = $pconfig['radius_timeout']; } else { $server['radius_timeout'] = 5; } if ($pconfig['radius_srvcs'] == "both") { $server['radius_auth_port'] = $pconfig['radius_auth_port']; $server['radius_acct_port'] = $pconfig['radius_acct_port']; } if ($pconfig['radius_srvcs'] == "auth") { $server['radius_auth_port'] = $pconfig['radius_auth_port']; unset($server['radius_acct_port']); } } if (isset($id) && isset($config['system']['authserver'][$id])) { $config['system']['authserver'][$id] = $server; } else { $config['system']['authserver'][] = $server; } write_config(); header("Location: system_authservers.php"); } else { $act = "edit"; } } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) { /* Remove server from main list. */ $serverdeleted = $a_server[$id]['name']; foreach ($config['system']['authserver'] as $k => $as) { if ($config['system']['authserver'][$k]['name'] == $serverdeleted) { unset($config['system']['authserver'][$k]); } } $savemsg = gettext("Authentication Server")." {$serverdeleted} ". gettext("deleted")."
"; write_config($savemsg); header("Location: system_authservers.php"); } } // list of all possible fields for auth item (used for form init) $all_authfields = array('type','name','ldap_caref','ldap_host','ldap_port','ldap_urltype','ldap_protver','ldap_scope', 'ldap_basedn','ldap_authcn','ldap_extended_query','ldap_binddn','ldap_bindpw','ldap_attr_user','radius_host', 'radius_auth_port','radius_acct_port','radius_secret','radius_timeout','radius_srvcs' ); foreach ($all_authfields as $fieldname) { if (!isset($pconfig[$fieldname])) { $pconfig[$fieldname] = null; } } legacy_html_escape_form_data($pconfig); legacy_html_escape_form_data($a_server); include("head.inc"); $main_buttons = array(); if (!isset($_GET['act']) || $_GET['act'] != 'new') { $main_buttons[] = array('label'=>gettext('Add server'), 'href'=>'system_authservers.php?act=new'); } ?>
0) { print_input_errors($input_errors); } ?>
  " />

  " data-toggle="tooltip" class="act_delete btn btn-default btn-xs">