diff --git a/go.mod b/go.mod index 1d0242ab..369a2364 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/mattn/go-sqlite3 v1.14.15 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/russross/blackfriday/v2 v2.1.0 - gopkg.in/ldap.v2 v2.5.1 ) require ( @@ -48,9 +47,6 @@ require ( golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace gopkg.in/asn1-ber.v1 => github.com/go-asn1-ber/asn1-ber v1.5.0 diff --git a/go.sum b/go.sum index ea7bcc68..f7fee7d4 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,6 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-asn1-ber/asn1-ber v1.5.0 h1:/S4hO/AO6tLMlPX0oftGSOcdGJJN/MuYzfgWRMn199E= -github.com/go-asn1-ber/asn1-ber v1.5.0/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-asn1-ber/asn1-ber v1.5.4 h1:vXT6d/FNDiELJnLb6hGNa309LMsrCoYFvpwHDF0+Y1A= github.com/go-asn1-ber/asn1-ber v1.5.4/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -555,8 +553,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU= -gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/utils/ldap.go b/utils/ldap.go index 14aa02ef..2b98bebd 100644 --- a/utils/ldap.go +++ b/utils/ldap.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/beego/beego/v2/core/logs" - "gopkg.in/ldap.v2" + "github.com/go-ldap/ldap/v3" ) /* @@ -23,9 +23,9 @@ ldap: func ValidLDAPLogin(password string) (result bool, err error) { result = false err = nil - lc, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", "192.168.3.104", 389)) + lc, err := ldap.DialURL(fmt.Sprintf("ldap://%s:%d", "192.168.3.104", 389)) if err != nil { - logs.Error("Dial => ", err) + logs.Error("DialURL => ", err) return } @@ -66,9 +66,9 @@ func ValidLDAPLogin(password string) (result bool, err error) { } func AddMember(account, password string) error { - lc, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", "192.168.3.104", 389)) + lc, err := ldap.DialURL(fmt.Sprintf("ldap://%s:%d", "192.168.3.104", 389)) if err != nil { - logs.Error("Dial => ", err) + logs.Error("DialURL => ", err) return err } @@ -102,9 +102,9 @@ func AddMember(account, password string) error { } func ModifyPassword(account, old_password, new_password string) error { - l, err := ldap.Dial("tcp", fmt.Sprintf("%s:%d", "192.168.3.104", 389)) + l, err := ldap.DialURL(fmt.Sprintf("ldap://%s:%d", "192.168.3.104", 389)) if err != nil { - logs.Error("Dial => ", err) + logs.Error("DialURL => ", err) } defer l.Close()