summaryrefslogtreecommitdiffstats
path: root/app/plugin_api.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-08-29 14:07:27 -0400
committerChristopher Speller <crspeller@gmail.com>2018-08-29 11:07:27 -0700
commit9c76d9ba0031ee4175db6960024d61c23cc98659 (patch)
tree798c48c4064fcafe2401516436967af208288b1d /app/plugin_api.go
parent0da5c852f05faf6c08026b9a16f8362564b27915 (diff)
downloadchat-9c76d9ba0031ee4175db6960024d61c23cc98659.tar.gz
chat-9c76d9ba0031ee4175db6960024d61c23cc98659.tar.bz2
chat-9c76d9ba0031ee4175db6960024d61c23cc98659.zip
Add GetLDAPUserAttributes method to the plugin API (#9326)
Diffstat (limited to 'app/plugin_api.go')
-rw-r--r--app/plugin_api.go16
1 files changed, 16 insertions, 0 deletions
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)