Skip to content

Commit

Permalink
Fix DIGEST-MD5 auth
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-igoshin committed Jan 9, 2025
1 parent 5b81530 commit eb8d32f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions v3/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,34 @@ func (l *Conn) DigestMD5Bind(digestMD5BindRequest *DigestMD5BindRequest) (*Diges
if err != nil {
return nil, fmt.Errorf("read packet: %s", err)
}

if len(packet.Children) == 2 {
response := packet.Children[1]
if response == nil {
return result, GetLDAPError(packet)
}
if response.ClassType == ber.ClassApplication && response.TagType == ber.TypeConstructed && len(response.Children) >= 3 {
if ber.Type(response.Children[0].Tag) == ber.Type(ber.TagInteger) || ber.Type(response.Children[0].Tag) == ber.Type(ber.TagEnumerated) {
resultCode := uint16(response.Children[0].Value.(int64))
if resultCode == 14 {
msgCtx, err := l.doRequest(digestMD5BindRequest)
if err != nil {
return nil, err
}
defer l.finishMessage(msgCtx)
packetResponse, ok := <-msgCtx.responses
if !ok {
return nil, NewError(ErrorNetwork, errors.New("ldap: response channel closed"))
}
packet, err = packetResponse.ReadPacket()
l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
if err != nil {
return nil, fmt.Errorf("read packet: %s", err)
}
}
}
}
}
}

err = GetLDAPError(packet)
Expand Down

0 comments on commit eb8d32f

Please sign in to comment.