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")