Fix potential error scoping issue.

Ping #1262
This commit is contained in:
Jeff Mitchell 2016-03-30 19:48:23 -04:00
parent 61a4f4a6a2
commit aa6a5fa25b

View File

@ -243,6 +243,7 @@ func (c *ConfigEntry) DialLDAP() (*ldap.Conn, error) {
} }
var conn *ldap.Conn var conn *ldap.Conn
var tlsConfig *tls.Config
switch u.Scheme { switch u.Scheme {
case "ldap": case "ldap":
if port == "" { if port == "" {
@ -250,7 +251,7 @@ func (c *ConfigEntry) DialLDAP() (*ldap.Conn, error) {
} }
conn, err = ldap.Dial("tcp", host+":"+port) conn, err = ldap.Dial("tcp", host+":"+port)
if c.StartTLS { if c.StartTLS {
tlsConfig, err := c.GetTLSConfig(host) tlsConfig, err = c.GetTLSConfig(host)
if err != nil { if err != nil {
break break
} }
@ -260,7 +261,7 @@ func (c *ConfigEntry) DialLDAP() (*ldap.Conn, error) {
if port == "" { if port == "" {
port = "636" port = "636"
} }
tlsConfig, err := c.GetTLSConfig(host) tlsConfig, err = c.GetTLSConfig(host)
if err != nil { if err != nil {
break break
} }