Skip to content

Commit d952dc3

Browse files
committed
Merge remote-tracking branch 'origin/main' into develop
2 parents 79c9cc7 + 7b87894 commit d952dc3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

providers/directory/search.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ import (
2222

2323
type predicate func(entry Entry) bool
2424

25+
var matchingRules = map[string]string{
26+
"1.3.6.1.4.1.1466.115.121.1.38": "objectIdentifierMatch",
27+
"1.3.6.1.4.1.1466.115.121.1.15": "caseIgnoreMatch",
28+
"1.3.6.1.4.1.1466.115.121.1.26": "caseExactMatch",
29+
"1.3.6.1.4.1.1466.115.121.1.7": "booleanMatch",
30+
"1.3.6.1.4.1.1466.115.121.1.27": "integerMatch",
31+
"1.3.6.1.4.1.1466.115.121.1.12": "distinguishedNameMatch",
32+
"1.3.6.1.4.1.1466.115.121.1.24": "generalizedTimeMatch",
33+
"1.3.6.1.4.1.1466.115.121.1.5": "octetStringMatch",
34+
}
35+
36+
func inferMatchingRule(syntaxOID string) string {
37+
if v, ok := matchingRules[syntaxOID]; ok {
38+
return v
39+
}
40+
return "caseExactMatch"
41+
}
42+
2543
func (d *Directory) serveSearch(rw ldap.ResponseWriter, r *ldap.Request) {
2644
msg := r.Message.(*ldap.SearchRequest)
2745
m, doMonitor := monitor.LdapFromContext(r.Context)
@@ -347,6 +365,9 @@ func (p *parser) equal(name, value string) (predicate, error) {
347365
if p.s != nil {
348366
t, ok := p.s.AttributeTypes[name]
349367
if ok {
368+
if t.Equality == "" {
369+
t.Equality = inferMatchingRule(t.Syntax)
370+
}
350371
switch t.Equality {
351372
case "caseIgnoreMatch", "2.5.13.2":
352373
f = func(s string) bool {

0 commit comments

Comments
 (0)