diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-05-11 08:05:23 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-05-11 08:05:23 -0400 |
commit | 91557bbd978500388a11b99401783164e143a966 (patch) | |
tree | 676d6278d957df20f21d5e367d1f447ee281414e /cmd | |
parent | 11c60ea41afd419036edc54b5571f26ce680c93c (diff) | |
parent | 2b27e12445ba51e1fa1ab2aceac5fcb3de66845d (diff) | |
download | chat-91557bbd978500388a11b99401783164e143a966.tar.gz chat-91557bbd978500388a11b99401783164e143a966.tar.bz2 chat-91557bbd978500388a11b99401783164e143a966.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commands/ldap.go | 29 |
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 +} |