summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-08-13 09:58:38 +1000
committerAndrew Bartlett <abartlet@samba.org>2009-08-17 09:50:56 +1000
commit346aa6e093508f4e2918b20df452398ef332e416 (patch)
tree43d87439a929cfa2560b8d94820f085c03aa6589 /source4/dsdb/schema
parent2c23e7dc5a5d305406a156402ec805ed05e5a11f (diff)
downloadsamba-346aa6e093508f4e2918b20df452398ef332e416.tar.gz
samba-346aa6e093508f4e2918b20df452398ef332e416.tar.bz2
samba-346aa6e093508f4e2918b20df452398ef332e416.zip
s4:schema Provide a way to reference a loaded schema between ldbs
This allows us to load the schema against one ldb context, but apply it to another. This will be useful in the provision script, as we need the schema before we start the LDAP server backend. Adnrew Bartlett
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_set.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 5d78d0a0c6..630c0ba184 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -370,28 +370,24 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
static struct dsdb_schema *global_schema;
/**
- * Make this ldb use the 'global' schema, setup to avoid having multiple copies in this process
+ * Make this ldb use a specified schema, already fully calculated and belonging to another ldb
*/
-int dsdb_set_global_schema(struct ldb_context *ldb)
+int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
{
int ret;
- if (!global_schema) {
- return LDB_SUCCESS;
- }
-
- ret = ldb_set_opaque(ldb, "dsdb_schema", global_schema);
+ ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;
}
/* Set the new attributes based on the new schema */
- ret = dsdb_schema_set_attributes(ldb, global_schema, false);
+ ret = dsdb_schema_set_attributes(ldb, schema, false);
if (ret != LDB_SUCCESS) {
return ret;
}
- /* Keep a reference to this schema, just incase the global copy is replaced */
- if (talloc_reference(ldb, global_schema) == NULL) {
+ /* Keep a reference to this schema, just incase the original copy is replaced */
+ if (talloc_reference(ldb, schema) == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -399,6 +395,18 @@ int dsdb_set_global_schema(struct ldb_context *ldb)
}
/**
+ * Make this ldb use the 'global' schema, setup to avoid having multiple copies in this process
+ */
+int dsdb_set_global_schema(struct ldb_context *ldb)
+{
+ if (!global_schema) {
+ return LDB_SUCCESS;
+ }
+
+ return dsdb_reference_schema(ldb, global_schema);
+}
+
+/**
* Find the schema object for this ldb
*/
@@ -451,7 +459,7 @@ void dsdb_make_schema_global(struct ldb_context *ldb)
* schema itself to the directory.
*/
-WERROR dsdb_attach_schema_from_ldif(struct ldb_context *ldb, const char *pf, const char *df)
+WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const char *df)
{
struct ldb_ldif *ldif;
struct ldb_message *msg;