@@ -162,6 +162,8 @@ func connect(ctx context.Context, target *adauth.Target, opts *Options) (conn *l
162162
163163 err = tlsConn .HandshakeContext (ctx )
164164 if err != nil {
165+ _ = tcpConn .Close ()
166+
165167 return nil , err
166168 }
167169
@@ -217,9 +219,9 @@ func bind(
217219 switch {
218220 case opts .SimpleBind :
219221 switch {
220- case creds .Password == "" && ! creds .PasswordIsEmtpyString :
222+ case creds .Password == "" && ! creds .PasswordIsEmptyString :
221223 return fmt .Errorf ("specify a password for simple bind or -p '' for an unauthenticated simple bind" )
222- case creds .Password == "" && creds .PasswordIsEmtpyString :
224+ case creds .Password == "" && creds .PasswordIsEmptyString :
223225 opts .Debug ("using unauthenticated simple bind" )
224226 default :
225227 opts .Debug ("authenticating with simple bind" )
@@ -228,15 +230,15 @@ func bind(
228230 _ , err = conn .SimpleBind (& ldap.SimpleBindRequest {
229231 Username : creds .UPN (),
230232 Password : creds .Password ,
231- AllowEmptyPassword : creds .PasswordIsEmtpyString ,
233+ AllowEmptyPassword : creds .PasswordIsEmptyString ,
232234 })
233235 if err != nil {
234236 return fmt .Errorf ("simple bind: %w" , err )
235237 }
236238 case ! target .UseKerberos && creds .ClientCert == nil :
237239 opts .Debug ("authenticating using NTLM bind" )
238240
239- if ! creds .PasswordIsEmtpyString && (creds .Password == "" && creds .NTHash == "" ) {
241+ if ! creds .PasswordIsEmptyString && (creds .Password == "" && creds .NTHash == "" ) {
240242 return fmt .Errorf ("no credentials available for NTLM" )
241243 }
242244
@@ -245,7 +247,7 @@ func bind(
245247 Username : creds .Username ,
246248 Password : creds .Password ,
247249 Hash : creds .NTHash ,
248- AllowEmptyPassword : creds .PasswordIsEmtpyString ,
250+ AllowEmptyPassword : creds .PasswordIsEmptyString ,
249251 }
250252
251253 tlsState , ok := conn .TLSConnectionState ()
@@ -347,7 +349,7 @@ func kerberosClient(
347349 }
348350
349351 switch {
350- case creds .Password != "" || creds .PasswordIsEmtpyString :
352+ case creds .Password != "" || creds .PasswordIsEmptyString :
351353 opts .Debug ("authenticating using GSSAPI bind (password)" )
352354
353355 authClient = & gssapiClient {
0 commit comments