s4:dsdb/objectclass_attrs: call dsdb_attribute_from_ldb() without a prefixmap
authorStefan Metzmacher <metze@samba.org>
Mon, 8 Aug 2016 11:02:21 +0000 (13:02 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 10 Aug 2016 22:49:14 +0000 (00:49 +0200)
We may not have a prefix mapping for the new attribute definition,
it will be added later.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12128

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/dsdb/samdb/ldb_modules/objectclass_attrs.c

index e051913b2b92ca9303723aa9dd5a614c87cac0da..f739c40ac83c6ce4944347daffb06c8d3579a131 100644 (file)
@@ -437,13 +437,25 @@ static int attr_handler2(struct oc_context *ac)
                struct dsdb_attribute *att = talloc(ac, struct dsdb_attribute);
                const struct dsdb_syntax *attrSyntax;
                WERROR status;
-
-               status= dsdb_attribute_from_ldb(ac->schema, msg, att);
+               struct dsdb_schema *tmp_schema = NULL;
+
+               /*
+                * We temporary remove the prefix map from the schema,
+                * a new prefix map is added by dsdb_create_prefix_mapping()
+                * via the "schema_data" module.
+                */
+               tmp_schema = dsdb_schema_copy_shallow(ac, ldb, ac->schema);
+               if (tmp_schema == NULL) {
+                       return ldb_module_oom(ac->module);
+               }
+               TALLOC_FREE(tmp_schema->prefixmap);
+               status= dsdb_attribute_from_ldb(tmp_schema, msg, att);
                if (!W_ERROR_IS_OK(status)) {
                        ldb_set_errstring(ldb,
                                                "objectclass: failed to translate the schemaAttribute to a dsdb_attribute");
                        return LDB_ERR_UNWILLING_TO_PERFORM;
                }
+               TALLOC_FREE(tmp_schema);
 
                attrSyntax = dsdb_syntax_for_attribute(att);
                if (!attrSyntax) {