old_schema = ldb_get_opaque(ldb, "dsdb_schema");
- ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
+ ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
if (ret != LDB_SUCCESS) {
return ret;
}
- /* Remove the reference to the schema we just overwrote - if there was
- * none, NULL is harmless here */
- if (old_schema != schema) {
- talloc_unlink(ldb, old_schema);
- talloc_steal(ldb, schema);
- }
-
- talloc_steal(ldb, schema);
-
- ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
+ ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;
}
+ talloc_steal(ldb, schema);
+
/* Set the new attributes based on the new schema */
ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true);
if (ret != LDB_SUCCESS) {
return ret;
}
- return LDB_SUCCESS;
+ /*
+ * Remove the reference to the schema we just overwrote - if there was
+ * none, NULL is harmless here.
+ */
+ if (old_schema != schema) {
+ talloc_unlink(ldb, old_schema);
+ }
+
+ return ret;
}
/**