Avoid the use of extensibleObject in ldap mapping backend.
[kai/samba.git] / source / dsdb / samdb / ldb_modules / simple_ldap_map.c
index acf2fd622cc29ddb04134ec055d5dba6e5d53b99..e5541ea255dd927cd65a668eb4093a175298d1ce 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_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);
        }
@@ -668,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, "extensibleObject", NULL);
+       ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, "samba4Top", NULL);
         if (ret != LDB_SUCCESS)
                 return ret;
 
@@ -689,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, "extensibleObject", NULL);
+       ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, "samba4Top", NULL);
         if (ret != LDB_SUCCESS)
                 return ret;
 
@@ -793,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;
-}