Skip to content

Commit

Permalink
de-indent
Browse files Browse the repository at this point in the history
  • Loading branch information
rosecodym committed Jul 28, 2023
1 parent eb7669f commit 242903f
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions pkg/detectors/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,32 @@ func verifyLDAP(ctx context.Context, username, password string, ldapURL *url.URL
case "ldap":
// Non-TLS dial
l, err := ldap.DialURL(uri)
if err != nil {
return err
}
defer l.Close()
// Non-TLS verify
err = l.Bind(username, password)
if err == nil {
defer l.Close()
// Non-TLS verify
err = l.Bind(username, password)
if err == nil {
return nil
}
return nil
}

// STARTTLS
err = l.StartTLS(&tls.Config{InsecureSkipVerify: true})
if err == nil {
// STARTTLS verify
return l.Bind(username, password)
} else {
return err
}
} else {
// STARTTLS
err = l.StartTLS(&tls.Config{InsecureSkipVerify: true})
if err != nil {
return err
}
// STARTTLS verify
return l.Bind(username, password)
case "ldaps":
// TLS dial
l, err := ldap.DialTLS("tcp", uri, &tls.Config{InsecureSkipVerify: true})
if err == nil {
defer l.Close()
// TLS verify
return l.Bind(username, password)
} else {
if err != nil {
return err
}
defer l.Close()
// TLS verify
return l.Bind(username, password)
}

return fmt.Errorf("unknown ldap scheme %q", ldapURL.Scheme)
Expand Down

0 comments on commit 242903f

Please sign in to comment.