...
1 package ldap
2
3 import (
4 "errors"
5
6 ber "github.com/go-asn1-ber/asn1-ber"
7 )
8
9
10 var ErrConnUnbound = NewError(ErrorNetwork, errors.New("ldap: connection is closed"))
11
12 type unbindRequest struct{}
13
14 func (unbindRequest) appendTo(envelope *ber.Packet) error {
15 envelope.AppendChild(ber.Encode(ber.ClassApplication, ber.TypePrimitive, ApplicationUnbindRequest, nil, ApplicationMap[ApplicationUnbindRequest]))
16 return nil
17 }
18
19
20
21
22 func (l *Conn) Unbind() error {
23 if l.IsClosing() {
24 return ErrConnUnbound
25 }
26
27 _, err := l.doRequest(unbindRequest{})
28 if err != nil {
29 return err
30 }
31
32
33
34
35 l.Close()
36
37 return nil
38 }
39
View as plain text