diff options
author | Jeroen Simonetti <jsimonetti@users.noreply.github.com> | 2016-06-01 16:55:37 +0200 |
---|---|---|
committer | Ned McClain <ned@appliedtrust.com> | 2016-06-01 16:55:37 +0200 |
commit | 6e14e82719330c918c5b4139cc80c51d7ebc5fba (patch) | |
tree | 45b21429cdd2561311573efd300c60604fcf7e5e | |
parent | Fix issue where ManageDSAit control sent (#3) (diff) | |
download | ldap-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 |
-rw-r--r-- | filter.go | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -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 |