Source
input.name = 'ldap_servers[' + ldap.row_index + '][provision_groups][' + group_index + '][user_groups][][usrgrpid]';
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* @var CView $this
*/
?>
<script>
const view = new class {
init({ldap_servers, ldap_default_row_index, db_authentication_type, saml_provision_groups,
saml_provision_media, templates, mfa_methods, mfa_default_row_index, is_http_auth_allowed
}) {
this.form = document.getElementById('authentication-form');
this.db_authentication_type = db_authentication_type;
this.saml_provision_status = document.getElementById('saml_provision_status');
this.saml_provision_groups_table = document.getElementById('saml-group-table');
this.saml_media_type_mapping_table = document.getElementById('saml-media-type-mapping-table');
this.ldap_jit_status = document.getElementById('ldap_jit_status');
this.ldap_servers_table = document.getElementById('ldap-servers');
this.templates = templates;
this.is_http_auth_allowed = is_http_auth_allowed;
this.ldap_provisioning_fields = this.form.querySelectorAll(
'[name="ldap_jit_status"],[name="ldap_case_sensitive"],[name="jit_provision_interval"]'
);
this.jit_provision_interval = this.form.querySelector('[name="jit_provision_interval"]');
this.ldap_auth_enabled = this.form.querySelector('[type="checkbox"][name="ldap_auth_enabled"]');
this.mfa_table = document.getElementById('mfa-methods');
const saml_readonly = !this.form.querySelector('[type="checkbox"][name="saml_auth_enabled"]').checked;
const ldap_disabled = this.ldap_auth_enabled === null || !this.ldap_auth_enabled.checked;
const mfa_readonly = !this.form.querySelector('[type="checkbox"][name="mfa_status"]').checked;
this._addEventListeners();
this._addLdapServers(ldap_servers, ldap_default_row_index);
this.#setTableVisiblityState(this.ldap_servers_table, ldap_disabled);
this.#disableRemoveLinksWithUserGroups(this.ldap_servers_table);
this._renderProvisionGroups(saml_provision_groups);
this.#setTableVisiblityState(this.saml_provision_groups_table, saml_readonly);
this._renderProvisionMedia(saml_provision_media);
this.#setTableVisiblityState(this.saml_media_type_mapping_table, saml_readonly)
this.#addMfaMethods(mfa_methods, mfa_default_row_index);
this.#setTableVisiblityState(this.mfa_table, mfa_readonly);
this.#disableRemoveLinksWithUserGroups(this.mfa_table);
this.form.querySelector('[type="checkbox"][name="saml_auth_enabled"]').dispatchEvent(new Event('change'));
}
_addEventListeners() {
this.#addLdapSettingsEventListeners();
if (this.is_http_auth_allowed) {
document.getElementById('http_auth_enabled').addEventListener('change', (e) => {
this.form.querySelectorAll('[name^=http_]').forEach(field => {
if (!field.isSameNode(e.target)) {
field.disabled = !e.target.checked;
}
});
if (e.target.checked) {
let form_fields = this.form.querySelectorAll('[name^=http_]');
const http_auth_enabled = document.getElementById('http_auth_enabled');
overlayDialogue({
'title': <?= json_encode(_('Confirm changes')) ?>,
'class': 'position-middle',
'content': document.createElement('span').innerText = <?= json_encode(
_('Enable HTTP authentication for all users.')
) ?>,
'buttons': [
{
'title': <?= json_encode(_('Cancel')) ?>,
'cancel': true,
'class': '<?= ZBX_STYLE_BTN_ALT ?>',
'action': function () {
for (const form_field of form_fields) {
if (form_field !== http_auth_enabled) {
form_field.disabled = true;