From 7ff0a9d14e219c0d55ee35f96a47e6c64cf4d39e Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Fri, 21 Jul 2023 13:59:12 +0200 Subject: [PATCH] Implementing Activate User --- http-utils.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/http-utils.go b/http-utils.go index 6a6992e..04b5fc2 100644 --- a/http-utils.go +++ b/http-utils.go @@ -21,6 +21,13 @@ func logRequest(handler http.Handler) http.Handler { } func ldapOpen(w http.ResponseWriter) *ldap.Conn { + l, err := ldap.DialURL(config.LdapServerAddr) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + log.Printf(fmt.Sprintf("27: %v %v", err, l)) + return nil + } + if config.LdapTLS { err = l.StartTLS(&tls.Config{InsecureSkipVerify: true}) if err != nil { @@ -29,11 +36,5 @@ func ldapOpen(w http.ResponseWriter) *ldap.Conn { } } - l, err := ldap.DialURL(config.LdapServerAddr) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - log.Printf(fmt.Sprintf("27: %v %v", err, l)) - return nil - } return l }