diff options
author | Unknwon <u@gogs.io> | 2015-11-26 14:04:58 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-26 14:04:58 -0500 |
commit | aaa3f1b2b9de437386185670bcc135202f1d8099 (patch) | |
tree | 48790eed891ea75cf237f29d141eb0932f7bc3fd /modules/ldap/bind.go | |
parent | 2f28a0310b0f391dd74bb3a2ab0ae06379a4fb1a (diff) |
Use better LDAP lib and should fix #1139
Diffstat (limited to 'modules/ldap/bind.go')
-rw-r--r-- | modules/ldap/bind.go | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/modules/ldap/bind.go b/modules/ldap/bind.go deleted file mode 100644 index 0561e611..00000000 --- a/modules/ldap/bind.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ldap - -import ( - "errors" - - "github.com/gogits/gogs/modules/asn1-ber" -) - -func (l *Conn) Bind(username, password string) error { - messageID := l.nextMessageID() - - packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request") - packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID")) - bindRequest := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request") - bindRequest.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version")) - bindRequest.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, username, "User Name")) - bindRequest.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, password, "Password")) - packet.AppendChild(bindRequest) - - if l.Debug { - ber.PrintPacket(packet) - } - - channel, err := l.sendMessage(packet) - if err != nil { - return err - } - if channel == nil { - return NewError(ErrorNetwork, errors.New("ldap: could not send message")) - } - defer l.finishMessage(messageID) - - packet = <-channel - if packet == nil { - return NewError(ErrorNetwork, errors.New("ldap: could not retrieve response")) - } - - if l.Debug { - if err := addLDAPDescriptions(packet); err != nil { - return err - } - ber.PrintPacket(packet) - } - - resultCode, resultDescription := getLDAPResultCode(packet) - if resultCode != 0 { - return NewError(resultCode, errors.New(resultDescription)) - } - - return nil -} |