G Pas
This commit is contained in:
parent
be3874599c
commit
64a82df337
1 changed files with 10 additions and 2 deletions
12
utils.go
12
utils.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"math/rand"
|
||||
|
@ -11,15 +12,22 @@ import (
|
|||
)
|
||||
|
||||
func openLdap(config *ConfigFile) (*ldap.Conn, error) {
|
||||
var ldapConn *ldap.Conn
|
||||
var err error
|
||||
if config.LdapTLS {
|
||||
tlsConf := &tls.Config{
|
||||
ServerName: config.LdapServerAddr,
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
return ldap.DialTLS("tcp", net.JoinHostPort(config.LdapServerAddr, "636"), tlsConf)
|
||||
ldapConn, err = ldap.DialTLS("tcp", net.JoinHostPort(config.LdapServerAddr, "636"), tlsConf)
|
||||
} 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)
|
||||
// if err != nil {
|
||||
|
|
Loading…
Reference in a new issue