From 276e0189b1453b3b869f9ae834482d672b832158 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 1 Sep 2016 10:03:55 -0400 Subject: Making LDAP FirstName and LastName fields optional. (#3919) --- model/config.go | 8 -------- store/sql_user_store.go | 2 -- utils/config.go | 2 ++ webapp/components/admin_console/ldap_settings.jsx | 4 ++-- webapp/components/user_settings/user_settings_general.jsx | 4 +++- webapp/i18n/en.json | 4 ++-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/model/config.go b/model/config.go index 32cb501a0..eedd0d116 100644 --- a/model/config.go +++ b/model/config.go @@ -1013,14 +1013,6 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "") } - if *o.LdapSettings.FirstNameAttribute == "" { - return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_firstname", nil, "") - } - - if *o.LdapSettings.LastNameAttribute == "" { - return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_lastname", nil, "") - } - if *o.LdapSettings.EmailAttribute == "" { return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "") } diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 61bfa35b8..fff78c8f2 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -132,8 +132,6 @@ func (us SqlUserStore) Update(user *model.User, trustedUpdateData bool) StoreCha user.Email = oldUser.Email } else if user.IsLDAPUser() && !trustedUpdateData { if user.Username != oldUser.Username || - user.FirstName != oldUser.FirstName || - user.LastName != oldUser.LastName || user.Email != oldUser.Email { result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.can_not_change_ldap.app_error", nil, "user_id="+user.Id) storeChannel <- result diff --git a/utils/config.go b/utils/config.go index 9bb294281..bb21e50c1 100644 --- a/utils/config.go +++ b/utils/config.go @@ -281,6 +281,8 @@ func getClientConfig(c *model.Config) map[string]string { props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable) props["LdapLoginFieldName"] = *c.LdapSettings.LoginFieldName props["NicknameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.NicknameAttribute != "") + props["FirstNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.FirstNameAttribute != "") + props["LastNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.LastNameAttribute != "") } if *License.Features.MFA { diff --git a/webapp/components/admin_console/ldap_settings.jsx b/webapp/components/admin_console/ldap_settings.jsx index 32cdbab3a..23728870e 100644 --- a/webapp/components/admin_console/ldap_settings.jsx +++ b/webapp/components/admin_console/ldap_settings.jsx @@ -236,7 +236,7 @@ export default class LdapSettings extends AdminSettings { helpText={ } value={this.state.firstNameAttribute} @@ -255,7 +255,7 @@ export default class LdapSettings extends AdminSettings { helpText={ } value={this.state.lastNameAttribute} diff --git a/webapp/components/user_settings/user_settings_general.jsx b/webapp/components/user_settings/user_settings_general.jsx index cc63e4fbf..07af50059 100644 --- a/webapp/components/user_settings/user_settings_general.jsx +++ b/webapp/components/user_settings/user_settings_general.jsx @@ -629,7 +629,9 @@ class UserSettingsGeneralTab extends React.Component { if (this.props.activeSection === 'name') { let extraInfo; let submit = null; - if (this.props.user.auth_service === '') { + if (this.props.user.auth_service === '' || + (this.props.user.auth_service === 'ldap' && + (global.window.mm_config.FirstNameAttributeSet === 'false' || global.window.mm_config.LastNameAttributeSet === 'false'))) { inputs.push(