summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-01 07:02:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:01 -0500
commitbd7812be319556162b22562a7c9670dce00d90f9 (patch)
tree94b6315ceeea9b0ff4a5f42fb884f43c89e52772 /source4
parenta06d66a3a669c3a0a0f816438e2b3e91e208f398 (diff)
downloadsamba-bd7812be319556162b22562a7c9670dce00d90f9.tar.gz
samba-bd7812be319556162b22562a7c9670dce00d90f9.tar.bz2
samba-bd7812be319556162b22562a7c9670dce00d90f9.zip
r8038: - fixed indexing on binary values that need base64 encoding and canonicalisation
- added support for recognising the S- form of objectsid in search expressions. I thought this could be done with just a comparison modified comparison function, but it turns out it also needs a canonicalisation function so that indexing can work (This used to be commit 7d2bee2c5619f284375ecbed14371c5e8639ed1c)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c3
-rw-r--r--source4/lib/ldb/samba/ldif_handlers.c24
2 files changed, 24 insertions, 3 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 4d8a14f7f0..089c24eae4 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -118,9 +118,8 @@ static char *ldb_dn_key(struct ldb_context *ldb,
talloc_free(attr_folded);
return NULL;
}
-
if (ldb_should_b64_encode(&v)) {
- char *vstr = ldb_base64_encode(ldb, value->data, value->length);
+ char *vstr = ldb_base64_encode(ldb, v.data, v.length);
if (!vstr) return NULL;
ret = talloc_asprintf(ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr);
talloc_free(vstr);
diff --git a/source4/lib/ldb/samba/ldif_handlers.c b/source4/lib/ldb/samba/ldif_handlers.c
index 13499b8428..e364bf716d 100644
--- a/source4/lib/ldb/samba/ldif_handlers.c
+++ b/source4/lib/ldb/samba/ldif_handlers.c
@@ -85,9 +85,31 @@ static int ldb_comparison_objectSid(struct ldb_context *ldb,
strncmp(v2->data, "S-", 2) == 0) {
return strcmp(v1->data, v2->data);
}
+ if (strncmp(v1->data, "S-", 2) == 0) {
+ struct ldb_val v;
+ int ret;
+ if (ldif_read_objectSid(ldb, v1, &v) != 0) {
+ return -1;
+ }
+ ret = ldb_comparison_binary(ldb, &v, v2);
+ talloc_free(v.data);
+ return ret;
+ }
return ldb_comparison_binary(ldb, v1, v2);
}
+/*
+ canonicalise a objectSid
+*/
+static int ldb_canonicalise_objectSid(struct ldb_context *ldb, const struct ldb_val *in,
+ struct ldb_val *out)
+{
+ if (strncmp(in->data, "S-", 2) == 0) {
+ return ldif_read_objectSid(ldb, in, out);
+ }
+ return ldb_handler_copy(ldb, in, out);
+}
+
static const struct ldb_attrib_handler samba_handlers[] = {
{
@@ -95,7 +117,7 @@ static const struct ldb_attrib_handler samba_handlers[] = {
.flags = 0,
.ldif_read_fn = ldif_read_objectSid,
.ldif_write_fn = ldif_write_objectSid,
- .canonicalise_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_objectSid,
.comparison_fn = ldb_comparison_objectSid
}
};