Skip to content

Commit

Permalink
route fix : DN, Attributes and Filter are now case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeantet committed Aug 23, 2015
1 parent 19cd5fa commit 3a8d560
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions route.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ldapserver

import (
"log"
"strings"

ldap "github.com/vjeantet/goldap/message"
)
Expand Down Expand Up @@ -55,7 +56,7 @@ func (r *route) Match(m *Message) bool {
switch v := m.ProtocolOp().(type) {
case ldap.BindRequest:
if r.uAuthChoice == true {
if v.AuthenticationChoice() != r.sAuthChoice {
if strings.ToLower(v.AuthenticationChoice()) != r.sAuthChoice {
return false
}
}
Expand All @@ -69,13 +70,13 @@ func (r *route) Match(m *Message) bool {

case ldap.SearchRequest:
if r.uBasedn == true {
if string(v.BaseObject()) != r.sBasedn {
if strings.ToLower(string(v.BaseObject())) != r.sBasedn {
return false
}
}

if r.uFilter == true {
if v.FilterString() != r.sFilter {
if strings.ToLower(v.FilterString()) != r.sFilter {
return false
}
}
Expand All @@ -96,19 +97,19 @@ func (r *route) Label(label string) *route {
}

func (r *route) BaseDn(dn string) *route {
r.sBasedn = dn
r.sBasedn = strings.ToLower(dn)
r.uBasedn = true
return r
}

func (r *route) AuthenticationChoice(choice string) *route {
r.sAuthChoice = choice
r.sAuthChoice = strings.ToLower(choice)
r.uAuthChoice = true
return r
}

func (r *route) Filter(pattern string) *route {
r.sFilter = pattern
r.sFilter = strings.ToLower(pattern)
r.uFilter = true
return r
}
Expand Down

0 comments on commit 3a8d560

Please sign in to comment.