forked from mmitton/ldap
-
Notifications
You must be signed in to change notification settings - Fork 4
/
abandon.go
47 lines (36 loc) · 1.06 KB
/
abandon.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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 (
"fmt"
"github.com/mavricknz/asn1-ber"
)
// Will return an error. Normally due to closed connection.
func (l *LDAPConnection) Abandon(abandonMessageID uint64) error {
messageID, ok := l.nextMessageID()
if !ok {
return NewLDAPError(ErrorClosing, "MessageID channel is closed.")
}
encodedAbandon := ber.NewInteger(ber.ClassApplication, ber.TypePrimative, ApplicationAbandonRequest, abandonMessageID, ApplicationMap[ApplicationAbandonRequest])
packet, err := requestBuildPacket(messageID, encodedAbandon, nil)
if err != nil {
return err
}
if l.Debug {
ber.PrintPacket(packet)
}
channel, err := l.sendMessage(packet)
if err != nil {
return err
}
if channel == nil {
return NewLDAPError(ErrorNetwork, "Could not send message")
}
defer l.finishMessage(messageID)
if l.Debug {
fmt.Printf("%d: NOT waiting Abandon for response\n", messageID)
}
// success
return nil
}