@@ -22,6 +22,24 @@ import (
2222
2323type 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+
2543func (d * Directory ) serveSearch (rw ldap.ResponseWriter , r * ldap.Request ) {
2644 msg := r .Message .(* ldap.SearchRequest )
2745 m , doMonitor := monitor .LdapFromContext (r .Context )
@@ -343,6 +361,9 @@ func (p *parser) equal(name, value string) (predicate, error) {
343361 if p .s != nil {
344362 t , ok := p .s .AttributeTypes [name ]
345363 if ok {
364+ if t .Equality == "" {
365+ t .Equality = inferMatchingRule (t .Syntax )
366+ }
346367 switch t .Equality {
347368 case "caseIgnoreMatch" , "2.5.13.2" :
348369 f = func (s string ) bool {
0 commit comments