Release connection after search ldap user

Fixes: 12162

Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
stonezdj 2020-07-21 18:00:39 +08:00
parent cae087ba49
commit 07694db90d
2 changed files with 2 additions and 2 deletions

View File

@ -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, "://")

View File

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