Debug connecting to the LDAP server

This commit is contained in:
Gregory Wells
2026-03-24 18:08:36 -04:00
parent 5aa2ce47c7
commit d62e1f7b8f
2 changed files with 36 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
package logging
import "log"
import (
"fmt"
"log"
)
type EventType int
@@ -16,6 +19,30 @@ func Infof(message string, vars ...any) {
log.Printf(message, vars...)
}
func Debug(message string) {
log.Printf("Warn: %s", message)
}
func Debugf(message string, v ...any) {
log.Printf("Warn: %s", fmt.Sprintf(message, v...))
}
func Warn(message string) {
log.Printf("Warn: %s", message)
}
func Warnf(message string, v ...any) {
log.Printf("Warn: %s", fmt.Sprintf(message, v...))
}
func Error(message string) {
log.Printf("Error: %s", message)
}
func Errorf(message string, v ...any) {
log.Printf("Error: %s", fmt.Sprintf(message, v...))
}
func Fatal(message string) {
log.Fatal(message)
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"log"
"astraltech.xyz/accountmanager/src/logging"
"github.com/go-ldap/ldap/v3"
)
@@ -21,15 +22,21 @@ type LDAPSearch struct {
}
func connectToLDAPServer(URL string, starttls bool, ignore_cert bool) (*LDAPServer, error) {
logging.Debugf("Connecting to LDAP server %s", URL)
l, err := ldap.DialURL(URL)
if err != nil {
logging.Fatal("Failed to connect to LDAP server")
logging.Fatal(err.Error())
return nil, err
}
logging.Infof("Connected to LDAP server")
if starttls {
logging.Debugf("Enabling StartTLS")
if err := l.StartTLS(&tls.Config{InsecureSkipVerify: ignore_cert}); err != nil {
log.Println("StartTLS failed:", err)
logging.Errorf("StartTLS failed %s", err.Error())
}
logging.Infof("StartTLS enabled")
}
return &LDAPServer{