Skip to content

Commit

Permalink
Merge pull request #142 from jefferai/master
Browse files Browse the repository at this point in the history
Fix control packets being encoded when none exist on bind
  • Loading branch information
johnweldon authored Dec 9, 2017
2 parents 0ae9f24 + 69cb73b commit 23c4ee2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (bindRequest *SimpleBindRequest) encode() *ber.Packet {
request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, bindRequest.Username, "User Name"))
request.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, bindRequest.Password, "Password"))

request.AppendChild(encodeControls(bindRequest.Controls))
if len(bindRequest.Controls) > 0 {
request.AppendChild(encodeControls(bindRequest.Controls))
}

return request
}
Expand Down
2 changes: 1 addition & 1 deletion del.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (l *Conn) Del(delRequest *DelRequest) error {
packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
packet.AppendChild(delRequest.encode())
if delRequest.Controls != nil {
if len(delRequest.Controls) > 0 {
packet.AppendChild(encodeControls(delRequest.Controls))
}

Expand Down
2 changes: 1 addition & 1 deletion search.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) {
}
packet.AppendChild(encodedSearchRequest)
// encode search controls
if searchRequest.Controls != nil {
if len(searchRequest.Controls) > 0 {
packet.AppendChild(encodeControls(searchRequest.Controls))
}

Expand Down

0 comments on commit 23c4ee2

Please sign in to comment.