Merge pull request #12543 from stonezdj/200721_release_conn_ldap

Release connection after search ldap user
This commit is contained in:
stonezdj(Daojun Zhang) 2020-07-23 11:06:14 +08:00 committed by GitHub
commit 8bbfb811a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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")