Avoid the use of extensibleObject in ldap mapping backend.
[kai/samba.git] / source4 / dsdb / samdb / ldb_modules / simple_ldap_map.c
index 070ce6ae6974aa202d90bdf5a127deceb2fd1e01..e5541ea255dd927cd65a668eb4093a175298d1ce 100644 (file)
@@ -71,7 +71,7 @@ static struct ldb_val guid_always_string(struct ldb_module *module, TALLOC_CTX *
                if (guid == NULL) {
                        return out;
                }
-               ndr_err = ndr_pull_struct_blob(val, guid, guid,
+               ndr_err = ndr_pull_struct_blob(val, guid, NULL, guid,
                                               (ndr_pull_flags_fn_t)ndr_pull_GUID);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        talloc_free(guid);
@@ -116,7 +116,7 @@ static struct ldb_val guid_ns_string(struct ldb_module *module, TALLOC_CTX *ctx,
                if (guid_p == NULL) {
                        return out;
                }
-               ndr_err = ndr_pull_struct_blob(val, guid_p, guid_p,
+               ndr_err = ndr_pull_struct_blob(val, guid_p, NULL, guid_p,
                                               (ndr_pull_flags_fn_t)ndr_pull_GUID);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        talloc_free(guid_p);
@@ -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_validate(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);
        }
@@ -375,15 +383,6 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
                         }
                }
        },
-       {
-               .local_name = "dn",
-               .type = MAP_RENAME,
-               .u = {
-                       .rename = {
-                                .remote_name = "entryDN"
-                        }
-               }
-       },
        {
                .local_name = "groupType",
                .type = MAP_CONVERT,
@@ -457,6 +456,7 @@ static const char * const entryuuid_wildcard_attributes[] = {
        "whenChanged",
        "usnCreated",
        "usnChanged",
+       "memberOf",
        NULL
 };
 
@@ -533,15 +533,6 @@ static const struct ldb_map_attribute nsuniqueid_attributes[] =
                         }
                }
        },
-       {
-               .local_name = "dn",
-               .type = MAP_RENAME,
-               .u = {
-                       .rename = {
-                                .remote_name = "entryDN"
-                        }
-               }
-       },
        {
                .local_name = "groupType",
                .type = MAP_CONVERT,
@@ -685,7 +676,7 @@ static int entryuuid_init(struct ldb_module *module)
        struct map_private *map_private;
        struct entryuuid_private *entryuuid_private;
 
-       ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, NULL);
+       ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, "samba4Top", NULL);
         if (ret != LDB_SUCCESS)
                 return ret;
 
@@ -706,7 +697,7 @@ static int nsuniqueid_init(struct ldb_module *module)
        struct map_private *map_private;
        struct entryuuid_private *entryuuid_private;
 
-       ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, NULL);
+       ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, "samba4Top", NULL);
         if (ret != LDB_SUCCESS)
                 return ret;
 
@@ -810,42 +801,16 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque
        return LDB_SUCCESS;
 }
 
-static struct ldb_module_ops entryuuid_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_entryuuid_module_ops = {
        .name              = "entryuuid",
        .init_context      = entryuuid_init,
-       .sequence_number   = entryuuid_sequence_number
+       .sequence_number   = entryuuid_sequence_number,
+       LDB_MAP_OPS
 };
 
-static struct ldb_module_ops nsuniqueid_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_nsuniqueid_module_ops = {
        .name              = "nsuniqueid",
        .init_context      = nsuniqueid_init,
-       .sequence_number   = entryuuid_sequence_number
+       .sequence_number   = entryuuid_sequence_number,
+       LDB_MAP_OPS
 };
-
-/* the init function */
-int ldb_simple_ldap_map_module_init(void)
-{
-       int ret;
-       struct ldb_module_ops ops = ldb_map_get_ops();
-       entryuuid_ops.add       = ops.add;
-       entryuuid_ops.modify    = ops.modify;
-       entryuuid_ops.del       = ops.del;
-       entryuuid_ops.rename    = ops.rename;
-       entryuuid_ops.search    = ops.search;
-       entryuuid_ops.wait      = ops.wait;
-       ret = ldb_register_module(&entryuuid_ops);
-
-       if (ret) {
-               return ret;
-       }
-
-       nsuniqueid_ops.add      = ops.add;
-       nsuniqueid_ops.modify   = ops.modify;
-       nsuniqueid_ops.del      = ops.del;
-       nsuniqueid_ops.rename   = ops.rename;
-       nsuniqueid_ops.search   = ops.search;
-       nsuniqueid_ops.wait     = ops.wait;
-       ret = ldb_register_module(&nsuniqueid_ops);
-
-       return ret;
-}