summaryrefslogtreecommitdiffstats
path: root/filter.go
diff options
context:
space:
mode:
authorJeroen Simonetti <jsimonetti@users.noreply.github.com>2016-06-01 16:55:37 +0200
committerNed McClain <ned@appliedtrust.com>2016-06-01 16:55:37 +0200
commit6e14e82719330c918c5b4139cc80c51d7ebc5fba (patch)
tree45b21429cdd2561311573efd300c60604fcf7e5e /filter.go
parentFix issue where ManageDSAit control sent (#3) (diff)
downloadldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar.gz
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar.bz2
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar.lz
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar.xz
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.tar.zst
ldap-6e14e82719330c918c5b4139cc80c51d7ebc5fba.zip
Diffstat (limited to 'filter.go')
-rw-r--r--filter.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/filter.go b/filter.go
index 0c9706a..df3c86a 100644
--- a/filter.go
+++ b/filter.go
@@ -306,8 +306,33 @@ func ServerApplyFilter(f *ber.Packet, entry *Entry) (bool, LDAPResultCode) {
} else if !ok {
return true, LDAPResultSuccess
}
- case "FilterSubstrings": // TODO
- return false, LDAPResultOperationsError
+ case "Substrings":
+ if len(f.Children) != 2 {
+ return false, LDAPResultOperationsError
+ }
+ attribute := f.Children[0].Value.(string)
+ bytes := f.Children[1].Children[0].Data.Bytes()
+ value := string(bytes[:])
+ for _, a := range entry.Attributes {
+ if strings.ToLower(a.Name) == strings.ToLower(attribute) {
+ for _, v := range a.Values {
+ switch f.Children[1].Children[0].Tag {
+ case FilterSubstringsInitial:
+ if strings.HasPrefix(v, value) {
+ return true, LDAPResultSuccess
+ }
+ case FilterSubstringsAny:
+ if strings.Contains(v, value) {
+ return true, LDAPResultSuccess
+ }
+ case FilterSubstringsFinal:
+ if strings.HasSuffix(v, value) {
+ return true, LDAPResultSuccess
+ }
+ }
+ }
+ }
+ }
case "FilterGreaterOrEqual": // TODO
return false, LDAPResultOperationsError
case "FilterLessOrEqual": // TODO