// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import * as Utils from 'utils/utils.jsx'; import AdminSettings from './admin_settings.jsx'; import BooleanSetting from './boolean_setting.jsx'; import ConnectionSecurityDropdownSetting from './connection_security_dropdown_setting.jsx'; import {FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; export default class LdapSettings extends AdminSettings { constructor(props) { super(props); this.getConfigFromState = this.getConfigFromState.bind(this); this.renderSettings = this.renderSettings.bind(this); this.state = Object.assign(this.state, { enable: props.config.LdapSettings.Enable, ldapServer: props.config.LdapSettings.LdapServer, ldapPort: props.config.LdapSettings.LdapPort, connectionSecurity: props.config.LdapSettings.ConnectionSecurity, baseDN: props.config.LdapSettings.BaseDN, bindUsername: props.config.LdapSettings.BindUsername, bindPassword: props.config.LdapSettings.BindPassword, userFilter: props.config.LdapSettings.UserFilter, firstNameAttribute: props.config.LdapSettings.FirstNameAttribute, lastNameAttribute: props.config.LdapSettings.LastNameAttribute, nicknameAttribute: props.config.LdapSettings.NicknameAttribute, emailAttribute: props.config.LdapSettings.EmailAttribute, usernameAttribute: props.config.LdapSettings.UsernameAttribute, idAttribute: props.config.LdapSettings.IdAttribute, skipCertificateVerification: props.config.LdapSettings.SkipCertificateVerification, queryTimeout: props.config.LdapSettings.QueryTimeout, loginFieldName: props.config.LdapSettings.LoginFieldName }); } getConfigFromState(config) { config.LdapSettings.Enable = this.state.enable; config.LdapSettings.LdapServer = this.state.ldapServer; config.LdapSettings.LdapPort = this.parseIntNonZero(this.state.ldapPort); config.LdapSettings.ConnectionSecurity = this.state.connectionSecurity; config.LdapSettings.BaseDN = this.state.baseDN; config.LdapSettings.BindUsername = this.state.bindUsername; config.LdapSettings.BindPassword = this.state.bindPassword; config.LdapSettings.UserFilter = this.state.userFilter; config.LdapSettings.FirstNameAttribute = this.state.firstNameAttribute; config.LdapSettings.LastNameAttribute = this.state.lastNameAttribute; config.LdapSettings.NicknameAttribute = this.state.nicknameAttribute; config.LdapSettings.EmailAttribute = this.state.emailAttribute; config.LdapSettings.UsernameAttribute = this.state.usernameAttribute; config.LdapSettings.IdAttribute = this.state.idAttribute; config.LdapSettings.SkipCertificateVerification = this.state.skipCertificateVerification; config.LdapSettings.QueryTimeout = this.parseIntNonZero(this.state.queryTimeout); config.LdapSettings.LoginFieldName = this.state.loginFieldName; return config; } renderTitle() { return (