summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
}
};