From 50ef597a69ce2826c610f3ab624c6ab9aada831d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 26 Mar 2019 05:36:35 -0700 Subject: [PATCH] Fixing GetLDAPUserAttributes to work with SAML as well. (#10498) --- app/plugin_api.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/plugin_api.go b/app/plugin_api.go index bcd9f887b1..1bb6f265f5 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -284,11 +284,17 @@ func (api *PluginAPI) GetLDAPUserAttributes(userId string, attributes []string) return nil, err } - if user.AuthService != model.USER_AUTH_SERVICE_LDAP || user.AuthData == nil { + if user.AuthData == nil { return map[string]string{}, nil } - return api.app.Ldap.GetUserAttributes(*user.AuthData, attributes) + // Only bother running the query if the user's auth service is LDAP or it's SAML and sync is enabled. + if user.AuthService == model.USER_AUTH_SERVICE_LDAP || + (user.AuthService == model.USER_AUTH_SERVICE_SAML && *api.app.Config().SamlSettings.EnableSyncWithLdap) { + return api.app.Ldap.GetUserAttributes(*user.AuthData, attributes) + } + + return map[string]string{}, nil } func (api *PluginAPI) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {