summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-11-29 13:28:33 +0200
committerKamen Mazdrashki <kamenim@samba.org>2010-12-01 13:01:16 +0200
commitfcc26c5d59b1f7519a9a813fd70d1139c9f6976c (patch)
tree3f2ceb5b2e49a57b23ede908acc60f4f95eee729
parent16bd9dd7aef2e92771cffc7be55d4f35687c0e64 (diff)
downloadsamba-fcc26c5d59b1f7519a9a813fd70d1139c9f6976c.tar.gz
samba-fcc26c5d59b1f7519a9a813fd70d1139c9f6976c.tar.bz2
samba-fcc26c5d59b1f7519a9a813fd70d1139c9f6976c.zip
s4-dsdb/schema: Add Schema shallow copy function
-rw-r--r--source4/dsdb/schema/schema_init.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index bcb51f6b1a..977941e584 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -43,6 +43,63 @@ struct dsdb_schema *dsdb_new_schema(TALLOC_CTX *mem_ctx)
return schema;
}
+struct dsdb_schema *dsdb_schema_copy_shallow(TALLOC_CTX *mem_ctx,
+ struct ldb_context *ldb,
+ const struct dsdb_schema *schema)
+{
+ int ret;
+ struct dsdb_class *cls;
+ struct dsdb_attribute *attr;
+ struct dsdb_schema *schema_copy;
+
+ schema_copy = dsdb_new_schema(mem_ctx);
+ if (!schema_copy) {
+ return NULL;
+ }
+
+ /* copy prexiMap & schemaInfo */
+ schema_copy->prefixmap = dsdb_schema_pfm_copy_shallow(schema_copy,
+ schema->prefixmap);
+ if (!schema_copy->prefixmap) {
+ return NULL;
+ }
+
+ schema_copy->schema_info = talloc_strdup(schema_copy, schema->schema_info);
+
+ /* copy classes and attributes*/
+ for (cls = schema->classes; cls; cls = cls->next) {
+ struct dsdb_class *class_copy = talloc_memdup(schema_copy,
+ cls, sizeof(*cls));
+ if (!class_copy) {
+ goto failed;
+ }
+ DLIST_ADD(schema_copy->classes, class_copy);
+ }
+ schema_copy->num_classes = schema->num_classes;
+
+ for (attr = schema->attributes; attr; attr = attr->next) {
+ struct dsdb_attribute *a_copy = talloc_memdup(schema_copy,
+ attr, sizeof(*attr));
+ if (!a_copy) {
+ goto failed;
+ }
+ DLIST_ADD(schema_copy->attributes, a_copy);
+ }
+ schema_copy->num_attributes = schema->num_attributes;
+
+ /* rebuild indexes */
+ ret = dsdb_setup_sorted_accessors(ldb, schema_copy);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
+
+ return schema_copy;
+
+failed:
+ talloc_free(schema_copy);
+ return NULL;
+}
+
WERROR dsdb_load_prefixmap_from_drsuapi(struct dsdb_schema *schema,
const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)