git.samba.org
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6d2edec
)
r26412: Add comments and refactor to reuse common code.
author
Andrew Bartlett
<abartlet@samba.org>
Wed, 12 Dec 2007 06:02:07 +0000
(07:02 +0100)
committer
Stefan Metzmacher
<metze@samba.org>
Fri, 21 Dec 2007 04:49:43 +0000
(
05:49
+0100)
Andrew Bartlett
(This used to be commit
a8b0f5af9afcc19bd869ff19e1456dbe9d2713b6
)
source4/dsdb/schema/schema_init.c
patch
|
blob
|
history
diff --git
a/source4/dsdb/schema/schema_init.c
b/source4/dsdb/schema/schema_init.c
index 278f18cf0d305a165f78df694b4a5d033a2c37d1..c301766c9deead79ee350e9a40bb5a8a64cfcc3d 100644
(file)
--- a/
source4/dsdb/schema/schema_init.c
+++ b/
source4/dsdb/schema/schema_init.c
@@
-3,7
+3,8
@@
DSDB schema header
Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
DSDB schema header
Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
-
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2007
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@
-1038,6
+1039,11
@@
WERROR dsdb_linked_attribute_lDAPDisplayName_list(const struct dsdb_schema *sche
return WERR_OK;
}
return WERR_OK;
}
+/**
+ * Attach the schema to an opaque pointer on the ldb, so ldb modules
+ * can find it
+ */
+
int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
{
int ret;
int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
{
int ret;
@@
-1052,8
+1058,14
@@
int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
return LDB_SUCCESS;
}
return LDB_SUCCESS;
}
+/**
+ * Global variable to hold one copy of the schema, used to avoid memory bloat
+ */
static struct dsdb_schema *global_schema;
static struct dsdb_schema *global_schema;
+/**
+ * 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)
{
int ret;
int dsdb_set_global_schema(struct ldb_context *ldb)
{
int ret;
@@
-1068,6
+1080,10
@@
int dsdb_set_global_schema(struct ldb_context *ldb)
return LDB_SUCCESS;
}
return LDB_SUCCESS;
}
+/**
+ * Find the schema object for this ldb
+ */
+
const struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb)
{
const void *p;
const struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb)
{
const void *p;
@@
-1087,18
+1103,14
@@
const struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb)
return schema;
}
return schema;
}
+/**
+ * Make the schema found on this ldb the 'global' schema
+ */
+
void dsdb_make_schema_global(struct ldb_context *ldb)
{
const void *p;
void dsdb_make_schema_global(struct ldb_context *ldb)
{
const void *p;
- const struct dsdb_schema *schema;
-
- /* see if we have a cached copy */
- p = ldb_get_opaque(ldb, "dsdb_schema");
- if (!p) {
- return;
- }
-
- schema = talloc_get_type(p, struct dsdb_schema);
+ const struct dsdb_schema *schema = dsdb_get_schema(ldb);
if (!schema) {
return;
}
if (!schema) {
return;
}
@@
-1109,6
+1121,13
@@
void dsdb_make_schema_global(struct ldb_context *ldb)
dsdb_set_global_schema(ldb);
}
dsdb_set_global_schema(ldb);
}
+
+/**
+ * Rather than read a schema from the LDB itself, read it from an ldif
+ * file. This allows schema to be loaded and used while adding the
+ * schema itself to the directory.
+ */
+
WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df)
{
struct ldb_ldif *ldif;
WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df)
{
struct ldb_ldif *ldif;