Author: idra Date: 2005-07-16 18:16:32 +0000 (Sat, 16 Jul 2005) New Revision: 8515
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8515 Log: ldb_dn_cmp now uses ldb_dn_compare so that the DNs are compared on a content level not ona form level, his means that the 2 DNs: a) cn= user, dc=this, dc = is,dc=test b) cn=user,dc=this,dc=is,dc=test are now identical even if the string form differ (spaces) Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c branches/SAMBA_4_0/source/lib/ldb/common/ldb_utf8.c branches/SAMBA_4_0/source/lib/ldb/include/ldb.h branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c Changeset: Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c 2005-07-16 16:12:14 UTC (rev 8514) +++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c 2005-07-16 18:16:32 UTC (rev 8515) @@ -450,6 +450,29 @@ return ldb_dn_compare_base(ldb, edn0, edn1); } +int ldb_dn_cmp(struct ldb_context *ldb, const char *dn0, const char *dn1) +{ + struct ldb_dn *edn0; + struct ldb_dn *edn1; + int ret; + + edn0 = ldb_dn_explode_casefold(ldb, dn0); + if (edn0 == NULL) return 0; + + edn1 = ldb_dn_explode_casefold(ldb, dn1); + if (edn1 == NULL) { + talloc_free(edn0); + return 0; + } + + ret = ldb_dn_compare(ldb, edn0, edn1); + + talloc_free(edn0); + talloc_free(edn1); + + return ret; +} + /* casefold a dn. We need to casefold the attribute names, and canonicalize attribute values of case insensitive attributes. Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_utf8.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/common/ldb_utf8.c 2005-07-16 16:12:14 UTC (rev 8514) +++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_utf8.c 2005-07-16 18:16:32 UTC (rev 8515) @@ -73,15 +73,6 @@ } /* - compare two basedn fields - return 0 for match -*/ -int ldb_dn_cmp(const char *dn1, const char *dn2) -{ - return ldb_caseless_cmp(dn1, dn2); -} - -/* compare two attributes return 0 for match */ Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-07-16 16:12:14 UTC (rev 8514) +++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-07-16 18:16:32 UTC (rev 8515) @@ -335,7 +335,7 @@ /* useful functions for ldb_message structure manipulation */ -int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); /* case-fold a DN */ Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c 2005-07-16 16:12:14 UTC (rev 8514) +++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c 2005-07-16 18:16:32 UTC (rev 8515) @@ -93,12 +93,14 @@ /* find dn in msgs[] */ -static struct ldb_message *msg_find(struct ldb_message **msgs, int count, +static struct ldb_message *msg_find(struct ldb_context *ldb, + struct ldb_message **msgs, + int count, const char *dn) { int i; for (i=0;i<count;i++) { - if (ldb_dn_cmp(dn, msgs[i]->dn) == 0) { + if (ldb_dn_cmp(ldb, dn, msgs[i]->dn) == 0) { return msgs[i]; } } @@ -119,7 +121,7 @@ /* do the adds and modifies */ for (i=0;i<count2;i++) { - msg = msg_find(msgs1, count1, msgs2[i]->dn); + msg = msg_find(ldb, msgs1, count1, msgs2[i]->dn); if (!msg) { if (options->verbose > 0) { ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]); @@ -139,7 +141,7 @@ /* do the deletes */ for (i=0;i<count1;i++) { - msg = msg_find(msgs2, count2, msgs1[i]->dn); + msg = msg_find(ldb, msgs2, count2, msgs1[i]->dn); if (!msg) { if (options->verbose > 0) { ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]); Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c 2005-07-16 16:12:14 UTC (rev 8514) +++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c 2005-07-16 18:16:32 UTC (rev 8515) @@ -55,10 +55,12 @@ exit(1); } +struct ldb_context *ldbsearch_ldb; + static int do_compare_msg(struct ldb_message **el1, - struct ldb_message **el2) + struct ldb_message **el2) { - return ldb_dn_cmp((*el1)->dn, (*el2)->dn); + return ldb_dn_cmp(ldbsearch_ldb, (*el1)->dn, (*el2)->dn); } static int do_search(struct ldb_context *ldb, @@ -79,6 +81,7 @@ printf("# returned %d records\n", ret); + ldbsearch_ldb = ldb; if (sort_attribs) { qsort(msgs, ret, sizeof(struct ldb_message *), (comparison_fn_t)do_compare_msg);