diff --git a/TODO b/TODO index 76b6b61..0f7b93f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,2 @@ - - add support for case insensitive matching - - add real dn parsing - add write support with an external journal diff --git a/ldap_match_mapped.c b/ldap_match_mapped.c index 7b38d11..6340620 100644 --- a/ldap_match_mapped.c +++ b/ldap_match_mapped.c @@ -4,6 +4,7 @@ #include "str.h" #include "uint32.h" #include "case.h" +#include #include #include @@ -126,6 +127,20 @@ int ldap_matchfilter_mapped(uint32 ofs,struct Filter* f) { return 1; } +/* return 0 if they didn't match, otherwise return length in b */ +static int match(const char* a,int len,const char* b) { + const char* A=a+len; + const char* B=b+strlen(b); + while (len>0 && A>a && B>b) { + --A; --B; --len; + while (*A==' ' && A>a) { --A; --len; } + while (*B==' ' && B>b) --B; + if (tolower(*A) != tolower(*B)) + return 0; + } + return strlen(B); +} + /* return non-zero if the record matches the search request */ int ldap_match_mapped(uint32 ofs,struct SearchRequest* sr) { unsigned int l,i; @@ -137,7 +152,8 @@ int ldap_match_mapped(uint32 ofs,struct SearchRequest* sr) { // puts("fail: baseObject longer than dn"); return 0; } - if (!byte_equal(sr->baseObject.s,sr->baseObject.l,map+k+l-sr->baseObject.l)) { + /* we want "o=foo, o=bar" and "o=FOO,o=baR" to be equal */ + if (!(l=match(sr->baseObject.s,sr->baseObject.l,map+k))) { // puts("fail: not suffix"); return 0; }