summaryrefslogtreecommitdiffstats
path: root/cmd/platform/ldap.go
blob: 8f3aa0c81b5fb872753ba7ccfda13b1efc91cbaf (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
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package main

import (
	"github.com/mattermost/platform/einterfaces"
	"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,
	)
}

func ldapSyncCmdF(cmd *cobra.Command, args []string) error {
	if ldapI := einterfaces.GetLdapInterface(); ldapI != nil {
		if err := ldapI.Syncronize(); err != nil {
			CommandPrintErrorln("ERROR: AD/LDAP Synchronization Failed")
		} else {
			CommandPrettyPrintln("SUCCESS: AD/LDAP Synchronization Complete")
		}
	}

	return nil
}