From 9c76d9ba0031ee4175db6960024d61c23cc98659 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 29 Aug 2018 14:07:27 -0400 Subject: Add GetLDAPUserAttributes method to the plugin API (#9326) --- app/plugin_api.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/plugin_api.go') diff --git a/app/plugin_api.go b/app/plugin_api.go index 503feabee..20a27316f 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -184,6 +184,22 @@ func (api *PluginAPI) UpdateUserStatus(userId, status string) (*model.Status, *m return api.app.GetStatus(userId) } +func (api *PluginAPI) GetLDAPUserAttributes(userId string, attributes []string) (map[string]string, *model.AppError) { + if api.app.Ldap == nil { + return nil, model.NewAppError("GetLdapUserAttributes", "ent.ldap.disabled.app_error", nil, "", http.StatusNotImplemented) + } + + user, err := api.app.GetUser(userId) + if err != nil { + return nil, err + } + + if user.AuthService != model.USER_AUTH_SERVICE_LDAP || user.AuthData == nil { + return map[string]string{}, nil + } + + return api.app.Ldap.GetUserAttributes(*user.AuthData, attributes) +} func (api *PluginAPI) CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError) { return api.app.CreateChannel(channel, false) -- cgit v1.2.3-1-g7c22