Skip to content

Commit

Permalink
check Version field of Bind requests by default
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinz01 committed Apr 15, 2024
1 parent a5e74f9 commit ad26c04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 7 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ func (s *LDAPServer) handleMessage(conn *Conn, msg *Message) {
LDAPResultProtocolError.AsResult("invalid Bind request received"))
return
}
// Handle this so that implementations don't have to
if req.Version != 3 {
log.Println("Unsupported LDAP version in Bind request:", req.Version)
conn.SendResult(msg.MessageID, nil, TypeBindResponseOp,
LDAPResultProtocolError.AsResult("unsupported LDAP version specified in Bind request"))
return
}
conn.asyncOperations.Wait()
s.Handler.Bind(conn, msg, req)
case TypeCompareRequestOp:
Expand Down
5 changes: 0 additions & 5 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ func (t *TestHandler) Add(conn *ldapserver.Conn, msg *ldapserver.Message, req *l
func (t *TestHandler) Bind(conn *ldapserver.Conn, msg *ldapserver.Message, req *ldapserver.BindRequest) {
log.Println("Bind request")
res := &ldapserver.BindResponse{}
if req.Version != 3 {
res.ResultCode = ldapserver.LDAPResultProtocolError
res.DiagnosticMessage = "the protocol version received is not supported"
conn.SendResult(msg.MessageID, nil, ldapserver.TypeBindResponseOp, res)
}
switch req.AuthType {
case ldapserver.AuthenticationTypeSimple:
log.Println("Simple authentication:", req.Name, req.Credentials.(string))
Expand Down

0 comments on commit ad26c04

Please sign in to comment.