The DN in objectCategory should, if possible, be returned pretty...
authorAndrew Bartlett <abartlet@samba.org>
Tue, 4 Mar 2008 02:40:50 +0000 (13:40 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 4 Mar 2008 02:40:50 +0000 (13:40 +1100)
This avoids going via the canonicalise_fn(), which will upper case the DN

Andrew Bartlett

source/dsdb/samdb/ldb_modules/normalise.c
source/dsdb/samdb/ldb_modules/simple_ldap_map.c

index 695393d4e8a7f18f5f1f076203b38aa9dd9b5355..a0eff43534d63b1a8a301f5e350f882c4c459b88 100644 (file)
@@ -106,8 +106,8 @@ static int normalise_search_callback(struct ldb_context *ldb, void *context, str
                        continue;
                }
                /* Look to see if this attributeSyntax is a DN */
-               if ((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") != 0) &&
-                   (strcmp(attribute->attributeSyntax_oid, "2.5.5.7") != 0)) {
+               if (!((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") == 0) ||
+                     (strcmp(attribute->attributeSyntax_oid, "2.5.5.7") == 0))) {
                        continue;
                }
                for (j = 0; j < ares->message->elements[i].num_values; j++) {
index 3f4c19d28521f6bf2c462842ab524afdbd0c84ee..91896d7247f53e549a0427dae803de3b4c156272 100644 (file)
@@ -153,9 +153,17 @@ static struct ldb_val sid_always_binary(struct ldb_module *module, TALLOC_CTX *c
 /* Ensure we always convert objectCategory into a DN */
 static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
 {
+       struct ldb_dn *dn;
        struct ldb_val out = data_blob(NULL, 0);
        const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, "objectCategory");
 
+       dn = ldb_dn_new(ctx, module->ldb, val->data);
+       if (dn && ldb_dn_is_valid(dn)) {
+               talloc_free(dn);
+               return val_copy(module, ctx, val);
+       }
+       talloc_free(dn);
+
        if (a->syntax->canonicalise_fn(module->ldb, ctx, val, &out) != LDB_SUCCESS) {
                return data_blob(NULL, 0);
        }