File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
pkg/cli/admin/groups/sync Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,13 @@ func (o *PruneOptions) Run() error {
168168 if err != nil {
169169 return err
170170 }
171- defer ldapClient .Close ()
171+ defer func () {
172+ // Unbind does polite quit and closes the connection.
173+ // But when it fails, we need to ensure the connection is closed for sure.
174+ if err := ldapClient .Unbind (); err != nil {
175+ _ = ldapClient .Close ()
176+ }
177+ }()
172178
173179 pruneBuilder , err := buildPruneBuilder (ldapClient , o .Config )
174180 if err != nil {
Original file line number Diff line number Diff line change @@ -366,7 +366,13 @@ func (o *SyncOptions) Run() error {
366366 if err != nil {
367367 return err
368368 }
369- defer ldapClient .Close ()
369+ defer func () {
370+ // Unbind does polite quit and closes the connection.
371+ // But when it fails, we need to ensure the connection is closed for sure.
372+ if err := ldapClient .Unbind (); err != nil {
373+ _ = ldapClient .Close ()
374+ }
375+ }()
370376
371377 errorHandler := o .CreateErrorHandler ()
372378
You can’t perform that action at this time.
0 commit comments