Skip to content

Commit

Permalink
Return proper error code when exceeding size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
rhafer committed Jul 14, 2022
1 parent 419a21f commit 93d81ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/ldapserver/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func HandleSearchRequest(req *ber.Packet, controls *[]ldap.Control, messageID in

// size limit
if searchReq.SizeLimit > 0 && i >= searchReq.SizeLimit {
resultErr = ldap.NewError(
ldap.LDAPResultSizeLimitExceeded,
errors.New(ldap.LDAPResultCodeMap[ldap.LDAPResultSizeLimitExceeded]),
)
break
}
i++
Expand All @@ -85,7 +89,7 @@ func HandleSearchRequest(req *ber.Packet, controls *[]ldap.Control, messageID in
return &searchResp.Controls, ldap.NewError(ldap.LDAPResultOperationsError, err)
}
}
return &searchResp.Controls, nil
return &searchResp.Controls, resultErr
}

func parseSearchRequest(boundDN string, req *ber.Packet, controls *[]ldap.Control) (*ldap.SearchRequest, error) {
Expand Down

0 comments on commit 93d81ce

Please sign in to comment.