From d245b29f82a03f1aff966a2fb2100a5703d82f32 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 25 Jan 2017 09:32:42 -0500 Subject: More app code migration (#5170) * Migrate admin functions into app package * More user function refactoring * Move post functions into app package --- app/ldap.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/ldap.go (limited to 'app/ldap.go') diff --git a/app/ldap.go b/app/ldap.go new file mode 100644 index 000000000..fe68dfa81 --- /dev/null +++ b/app/ldap.go @@ -0,0 +1,40 @@ +// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "net/http" + + l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/einterfaces" + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" +) + +func SyncLdap() { + go func() { + if utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable { + if ldapI := einterfaces.GetLdapInterface(); ldapI != nil { + ldapI.SyncNow() + } else { + l4g.Error("%v", model.NewLocAppError("ldapSyncNow", "ent.ldap.disabled.app_error", nil, "").Error()) + } + } + }() +} + +func TestLdap() *model.AppError { + if ldapI := einterfaces.GetLdapInterface(); ldapI != nil && utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable { + if err := ldapI.RunTest(); err != nil { + err.StatusCode = 500 + return err + } + } else { + err := model.NewLocAppError("ldapTest", "ent.ldap.disabled.app_error", nil, "") + err.StatusCode = http.StatusNotImplemented + return err + } + + return nil +} -- cgit v1.2.3-1-g7c22