From 07694db90d53e2db294d7f31c4bdac349c146959 Mon Sep 17 00:00:00 2001 From: stonezdj Date: Tue, 21 Jul 2020 18:00:39 +0800 Subject: [PATCH] Release connection after search ldap user Fixes: 12162 Signed-off-by: stonezdj --- src/common/utils/ldap/ldap.go | 2 +- src/core/auth/ldap/ldap.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/utils/ldap/ldap.go b/src/common/utils/ldap/ldap.go index f54b566d5..98ebbdf73 100644 --- a/src/common/utils/ldap/ldap.go +++ b/src/common/utils/ldap/ldap.go @@ -235,7 +235,7 @@ func (session *Session) Bind(dn string, password string) error { return session.ldapConn.Bind(dn, password) } -// Open - open Session +// Open - open Session, should invoke Close for each Open call func (session *Session) Open() error { splitLdapURL := strings.Split(session.ldapConfig.LdapURL, "://") diff --git a/src/core/auth/ldap/ldap.go b/src/core/auth/ldap/ldap.go index 68797e873..7947975d2 100644 --- a/src/core/auth/ldap/ldap.go +++ b/src/core/auth/ldap/ldap.go @@ -154,7 +154,7 @@ func (l *Auth) SearchUser(username string) (*models.User, error) { if err = ldapSession.Open(); err != nil { return nil, fmt.Errorf("Failed to load system ldap config, %v", err) } - + defer ldapSession.Close() ldapUsers, err := ldapSession.SearchUser(username) if err != nil { return nil, fmt.Errorf("Failed to search user in ldap")