diff options
author | George Goldberg <george@gberg.me> | 2018-03-13 13:36:23 +0000 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2018-03-13 13:36:23 +0000 |
commit | fadcdd271a68b38571b75d1d38ab023f940ac83a (patch) | |
tree | 7f413edd35401b54b2f4eb4a687da1ac273bcd4b /cmd/commands/ldap.go | |
parent | b66e4bc932ed76c1cfd2b5f4ec0cfce70cd9fbb4 (diff) | |
parent | f2d26801b9647715fb43af873354d8def753868b (diff) | |
download | chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.tar.gz chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.tar.bz2 chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.zip |
Merge branch 'master' into advanced-permissions-phase-1
Diffstat (limited to 'cmd/commands/ldap.go')
-rw-r--r-- | cmd/commands/ldap.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/commands/ldap.go b/cmd/commands/ldap.go new file mode 100644 index 000000000..6938eae28 --- /dev/null +++ b/cmd/commands/ldap.go @@ -0,0 +1,48 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package commands + +import ( + "github.com/mattermost/mattermost-server/cmd" + "github.com/mattermost/mattermost-server/model" + "github.com/spf13/cobra" +) + +var LdapCmd = &cobra.Command{ + Use: "ldap", + Short: "LDAP related utilities", +} + +var LdapSyncCmd = &cobra.Command{ + Use: "sync", + Short: "Synchronize now", + Long: "Synchronize all LDAP users now.", + Example: " ldap sync", + RunE: ldapSyncCmdF, +} + +func init() { + LdapCmd.AddCommand( + LdapSyncCmd, + ) + cmd.RootCmd.AddCommand(LdapCmd) +} + +func ldapSyncCmdF(command *cobra.Command, args []string) error { + a, err := cmd.InitDBCommandContextCobra(command) + if err != nil { + return err + } + + if ldapI := a.Ldap; ldapI != nil { + job, err := ldapI.StartSynchronizeJob(true) + if err != nil || job.Status == model.JOB_STATUS_ERROR || job.Status == model.JOB_STATUS_CANCELED { + cmd.CommandPrintErrorln("ERROR: AD/LDAP Synchronization please check the server logs") + } else { + cmd.CommandPrettyPrintln("SUCCESS: AD/LDAP Synchronization Complete") + } + } + + return nil +} |