summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-05-10 09:46:09 -0700
committerGitHub <noreply@github.com>2018-05-10 09:46:09 -0700
commitd8dd271e43550ab043c2db36c274092d7819fcab (patch)
treee297c0534a9684d57fc254281cf5cbc3d7c08e0f /cmd
parentdb6b8f6238853c6e7e48dc8015a0b25f97ee232a (diff)
downloadchat-d8dd271e43550ab043c2db36c274092d7819fcab.tar.gz
chat-d8dd271e43550ab043c2db36c274092d7819fcab.tar.bz2
chat-d8dd271e43550ab043c2db36c274092d7819fcab.zip
MM-4998 Adding LoginIdAttribute to allow LDAP users to change their login ID without losing their account (#8756)
* Adding LoginIdAttribute * Modifying LDAP to use loginIDAttribute. * Adding IDAttribute migration and AD objectGUID support. * Removing unused idea. * Fix typo.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commands/ldap.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmd/commands/ldap.go b/cmd/commands/ldap.go
index 0c79ce32b..03c366213 100644
--- a/cmd/commands/ldap.go
+++ b/cmd/commands/ldap.go
@@ -22,9 +22,19 @@ var LdapSyncCmd = &cobra.Command{
RunE: ldapSyncCmdF,
}
+var LdapIdMigrate = &cobra.Command{
+ Use: "idmigrate",
+ Short: "Migrate LDAP IdAttribute to new value",
+ Long: "Migrate LDAP IdAttribute to new value. Run this utility then change the IdAttribute to the new value.",
+ Example: " ldap idmigrate objectGUID",
+ Args: cobra.ExactArgs(1),
+ RunE: ldapIdMigrateCmdF,
+}
+
func init() {
LdapCmd.AddCommand(
LdapSyncCmd,
+ LdapIdMigrate,
)
cmd.RootCmd.AddCommand(LdapCmd)
}
@@ -47,3 +57,22 @@ func ldapSyncCmdF(command *cobra.Command, args []string) error {
return nil
}
+
+func ldapIdMigrateCmdF(command *cobra.Command, args []string) error {
+ a, err := cmd.InitDBCommandContextCobra(command)
+ if err != nil {
+ return err
+ }
+ defer a.Shutdown()
+
+ toAttribute := args[0]
+ if ldapI := a.Ldap; ldapI != nil {
+ if err := ldapI.MigrateIDAttribute(toAttribute); err != nil {
+ cmd.CommandPrintErrorln("ERROR: AD/LDAP IdAttribute migration failed! Error: " + err.Error())
+ } else {
+ cmd.CommandPrettyPrintln("SUCCESS: AD/LDAP IdAttribute migration complete. You can now change your IdAttribute to: " + toAttribute)
+ }
+ }
+
+ return nil
+}