This commit is contained in:
Chris Mann 2023-07-23 14:07:08 +02:00
parent be3874599c
commit 64a82df337

View file

@ -2,6 +2,7 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
"log"
"net" "net"
"math/rand" "math/rand"
@ -11,15 +12,22 @@ import (
) )
func openLdap(config *ConfigFile) (*ldap.Conn, error) { func openLdap(config *ConfigFile) (*ldap.Conn, error) {
var ldapConn *ldap.Conn
var err error
if config.LdapTLS { if config.LdapTLS {
tlsConf := &tls.Config{ tlsConf := &tls.Config{
ServerName: config.LdapServerAddr, ServerName: config.LdapServerAddr,
InsecureSkipVerify: true, InsecureSkipVerify: true,
} }
return ldap.DialTLS("tcp", net.JoinHostPort(config.LdapServerAddr, "636"), tlsConf) ldapConn, err = ldap.DialTLS("tcp", net.JoinHostPort(config.LdapServerAddr, "636"), tlsConf)
} else { } else {
return ldap.DialURL("ldap://" + config.LdapServerAddr) ldapConn, err = ldap.DialURL("ldap://" + config.LdapServerAddr)
} }
if err != nil {
log.Printf("openLDAP %v", err)
log.Printf("openLDAP %v", config.LdapServerAddr)
}
return ldapConn, err
// l, err := ldap.DialURL(config.LdapServerAddr) // l, err := ldap.DialURL(config.LdapServerAddr)
// if err != nil { // if err != nil {