diff options
author | ned <ned@appliedtrust.com> | 2014-11-23 20:03:05 +0100 |
---|---|---|
committer | ned <ned@appliedtrust.com> | 2014-11-23 20:03:05 +0100 |
commit | c43d537d5bb0eeb491153b00cdefcb54a6178187 (patch) | |
tree | 45187fde4a720d3f53d13ec45ac4fea8e27356e4 /filter.go | |
parent | LDAP server support (diff) | |
download | ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.gz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.bz2 ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.lz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.xz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.zst ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.zip |
Diffstat (limited to '')
-rw-r--r-- | filter.go | 39 |
1 files changed, 18 insertions, 21 deletions
@@ -246,9 +246,7 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) { } } -func ServerApplyFilter(f *ber.Packet, entry *Entry) (bool, uint64) { - //log.Printf("%# v", pretty.Formatter(entry)) - +func ServerApplyFilter(f *ber.Packet, entry *Entry) (bool, LDAPResultCode) { switch FilterMap[f.Tag] { default: //log.Fatalf("Unknown LDAP filter code: %d", f.Tag) @@ -308,30 +306,30 @@ func ServerApplyFilter(f *ber.Packet, entry *Entry) (bool, uint64) { } else if !ok { return true, LDAPResultSuccess } - case "FilterSubstrings": + case "FilterSubstrings": // TODO return false, LDAPResultOperationsError - case "FilterGreaterOrEqual": + case "FilterGreaterOrEqual": // TODO return false, LDAPResultOperationsError - case "FilterLessOrEqual": + case "FilterLessOrEqual": // TODO return false, LDAPResultOperationsError - case "FilterApproxMatch": + case "FilterApproxMatch": // TODO return false, LDAPResultOperationsError - case "FilterExtensibleMatch": + case "FilterExtensibleMatch": // TODO return false, LDAPResultOperationsError } return false, LDAPResultSuccess } -func GetFilterType(filter string) (string, error) { // TODO <- test this +func GetFilterObjectClass(filter string) (string, error) { f, err := CompileFilter(filter) if err != nil { return "", err } - return parseFilterType(f) + return parseFilterObjectClass(f) } -func parseFilterType(f *ber.Packet) (string, error) { - searchType := "" +func parseFilterObjectClass(f *ber.Packet) (string, error) { + objectClass := "" switch FilterMap[f.Tag] { case "Equality Match": if len(f.Children) != 2 { @@ -339,42 +337,41 @@ func parseFilterType(f *ber.Packet) (string, error) { } attribute := strings.ToLower(f.Children[0].Value.(string)) value := f.Children[1].Value.(string) - if attribute == "objectclass" { - searchType = strings.ToLower(value) + objectClass = strings.ToLower(value) } case "And": for _, child := range f.Children { - subType, err := parseFilterType(child) + subType, err := parseFilterObjectClass(child) if err != nil { return "", err } if len(subType) > 0 { - searchType = subType + objectClass = subType } } case "Or": for _, child := range f.Children { - subType, err := parseFilterType(child) + subType, err := parseFilterObjectClass(child) if err != nil { return "", err } if len(subType) > 0 { - searchType = subType + objectClass = subType } } case "Not": if len(f.Children) != 1 { return "", errors.New("Not filter must have only one child") } - subType, err := parseFilterType(f.Children[0]) + subType, err := parseFilterObjectClass(f.Children[0]) if err != nil { return "", err } if len(subType) > 0 { - searchType = subType + objectClass = subType } } - return strings.ToLower(searchType), nil + return strings.ToLower(objectClass), nil } |