blob: 0c79ce32bce528586c1095263cc8a6d4ce043235 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// 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
}
defer a.Shutdown()
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
}
|