Skip to content

Commit 1246ded

Browse files
committed
Refactor ldap
1 parent 0c2f6c7 commit 1246ded

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ldap/ldap_authenticator.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"crypto/tls"
66
"errors"
77
"fmt"
8-
"github.com/core-go/auth"
9-
"gopkg.in/ldap.v3"
108
"net"
119
"strconv"
1210
"strings"
1311
"time"
12+
13+
"github.com/core-go/auth"
14+
"github.com/go-ldap/ldap/v3"
1415
)
1516

1617
type LDAPAuthenticator struct {
@@ -52,12 +53,12 @@ func NewConn(c LDAPConfig) (*ldap.Conn, error) {
5253
}
5354
if c.TLS != nil && *c.TLS {
5455
if c.InsecureSkipVerify != nil && *c.InsecureSkipVerify {
55-
l, err = ldap.DialTLS("tcp", c.Server, &tls.Config{ServerName: c.Server, InsecureSkipVerify: true})
56+
l, err = ldap.DialURL(c.Server, ldap.DialWithTLSConfig(&tls.Config{ServerName: c.Server, InsecureSkipVerify: true}))
5657
} else {
57-
l, err = ldap.DialTLS("tcp", c.Server, &tls.Config{ServerName: c.Server})
58+
l, err = ldap.DialURL(c.Server, ldap.DialWithTLSConfig(&tls.Config{ServerName: c.Server}))
5859
}
5960
} else {
60-
l, err = ldap.Dial("tcp", c.Server)
61+
l, err = ldap.DialURL(c.Server)
6162
if err == nil {
6263
if c.StartTLS != nil && *c.StartTLS {
6364
if c.InsecureSkipVerify != nil && *c.InsecureSkipVerify {

0 commit comments

Comments
 (0)