mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-20 07:37:38 +01:00
Merge pull request #12543 from stonezdj/200721_release_conn_ldap
Release connection after search ldap user
This commit is contained in:
commit
8bbfb811a4
@ -235,7 +235,7 @@ func (session *Session) Bind(dn string, password string) error {
|
|||||||
return session.ldapConn.Bind(dn, password)
|
return session.ldapConn.Bind(dn, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open - open Session
|
// Open - open Session, should invoke Close for each Open call
|
||||||
func (session *Session) Open() error {
|
func (session *Session) Open() error {
|
||||||
|
|
||||||
splitLdapURL := strings.Split(session.ldapConfig.LdapURL, "://")
|
splitLdapURL := strings.Split(session.ldapConfig.LdapURL, "://")
|
||||||
|
@ -154,7 +154,7 @@ func (l *Auth) SearchUser(username string) (*models.User, error) {
|
|||||||
if err = ldapSession.Open(); err != nil {
|
if err = ldapSession.Open(); err != nil {
|
||||||
return nil, fmt.Errorf("Failed to load system ldap config, %v", err)
|
return nil, fmt.Errorf("Failed to load system ldap config, %v", err)
|
||||||
}
|
}
|
||||||
|
defer ldapSession.Close()
|
||||||
ldapUsers, err := ldapSession.SearchUser(username)
|
ldapUsers, err := ldapSession.SearchUser(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to search user in ldap")
|
return nil, fmt.Errorf("Failed to search user in ldap")
|
||||||
|
Loading…
Reference in New Issue
Block a user