mirror of
https://github.com/netauth/ldap.git
synced 2024-11-24 12:31:55 -06:00
internal/ldap: Fix search equivalence translation
This commit is contained in:
parent
4a82eb8228
commit
c4dd12c378
|
@ -123,7 +123,8 @@ func entitySearchExprHelper(attr, op, val string) (string, error) {
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case "=":
|
case "=":
|
||||||
operator = "="
|
operator = ":"
|
||||||
|
val = strconv.Quote(val)
|
||||||
default:
|
default:
|
||||||
return "", errors.New("search comparison is unsupported")
|
return "", errors.New("search comparison is unsupported")
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ func (s *server) handleSearchGroups(w ldap.ResponseWriter, m *ldap.Message) {
|
||||||
|
|
||||||
s.l.Debug("Searching groups", "expr", expr)
|
s.l.Debug("Searching groups", "expr", expr)
|
||||||
|
|
||||||
members, err := s.c.GroupSearch(ctx, expr)
|
groups, err := s.c.GroupSearch(ctx, expr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError)
|
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError)
|
||||||
res.SetDiagnosticMessage(err.Error())
|
res.SetDiagnosticMessage(err.Error())
|
||||||
|
@ -170,8 +171,9 @@ func (s *server) handleSearchGroups(w ldap.ResponseWriter, m *ldap.Message) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range members {
|
for i := range groups {
|
||||||
e, err := s.groupSearchResult(ctx, members[i], r.BaseObject(), r.Attributes())
|
s.l.Debug("Found group", "group", groups[i].GetName())
|
||||||
|
e, err := s.groupSearchResult(ctx, groups[i], r.BaseObject(), r.Attributes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError)
|
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError)
|
||||||
res.SetDiagnosticMessage(err.Error())
|
res.SetDiagnosticMessage(err.Error())
|
||||||
|
@ -214,14 +216,15 @@ func groupSearchExprHelper(attr, op, val string) (string, error) {
|
||||||
|
|
||||||
switch attr {
|
switch attr {
|
||||||
case "cn":
|
case "cn":
|
||||||
predicate = "name"
|
predicate = "Name"
|
||||||
default:
|
default:
|
||||||
return "", errors.New("search attribute is unsupported")
|
return "", errors.New("search attribute is unsupported")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case "=":
|
case "=":
|
||||||
operator = "="
|
operator = ":"
|
||||||
|
val = strconv.Quote(val)
|
||||||
default:
|
default:
|
||||||
return "", errors.New("search comparison is unsupported")
|
return "", errors.New("search comparison is unsupported")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue