summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/python/pyglue.c26
-rw-r--r--source4/scripting/python/samba/__init__.py3
-rw-r--r--source4/scripting/python/samba/provision.py14
-rw-r--r--source4/setup/provision_schema_basedn_modify.ldif3
4 files changed, 38 insertions, 8 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index f5694e162c..55ba5c37fc 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -344,6 +344,30 @@ static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self, PyObject *ar
return ret;
}
+static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb;
+ struct ldb_context *ldb;
+ WERROR result;
+ struct dsdb_schema *schema;
+
+ if (!PyArg_ParseTuple(args, "O", &py_ldb))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ schema = dsdb_get_schema(ldb);
+ if (!schema) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n");
+ return NULL;
+ }
+
+ result = dsdb_write_prefixes_from_schema_to_ldb(NULL, ldb, schema);
+ PyErr_WERROR_IS_ERR_RAISE(result);
+
+ Py_RETURN_NONE;
+}
+
static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
{
PyObject *py_ldb;
@@ -424,6 +448,8 @@ static PyMethodDef py_misc_methods[] = {
NULL },
{ "dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS,
NULL },
+ { "dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
+ NULL },
{ "dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
NULL },
{ "dsdb_convert_schema_to_openldap", (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 69a0320be7..4df3d6f55a 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -239,6 +239,9 @@ class Ldb(ldb.Ldb):
def set_schema_from_ldb(self, ldb):
glue.dsdb_set_schema_from_ldb(self, ldb)
+ def write_prefixes_from_schema(self):
+ glue.dsdb_write_prefixes_from_schema_to_ldb(self)
+
def convert_schema_to_openldap(self, target, mapping):
return glue.dsdb_convert_schema_to_openldap(self, target, mapping)
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index aa6b6789dd..a8cedaf23a 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -151,18 +151,21 @@ class Schema(object):
self.schema_data += open(setup_path("schema_samba4.ldif"), 'r').read()
self.schema_data = substitute_var(self.schema_data, {"SCHEMADN": schemadn})
check_all_substituted(self.schema_data)
- prefixmap = open(setup_path("prefixMap.txt"), 'r').read()
- prefixmap = b64encode(prefixmap)
-
+
self.schema_dn_modify = read_and_sub_file(setup_path("provision_schema_basedn_modify.ldif"),
{"SCHEMADN": schemadn,
- "PREFIXMAP_B64": prefixmap,
"SERVERDN": serverdn,
})
self.schema_dn_add = read_and_sub_file(setup_path("provision_schema_basedn.ldif"),
{"SCHEMADN": schemadn
})
- self.ldb.set_schema_from_ldif(self.schema_dn_modify, self.schema_data)
+
+ prefixmap = open(setup_path("prefixMap.txt"), 'r').read()
+ prefixmap = b64encode(prefixmap)
+
+ # We don't actually add this ldif, just parse it
+ prefixmap_ldif = "dn: cn=schema\nprefixMap:: %s\n\n" % prefixmap
+ self.ldb.set_schema_from_ldif(prefixmap_ldif, self.schema_data)
def check_install(lp, session_info, credentials):
@@ -910,6 +913,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
message("Setting up sam.ldb schema")
samdb.add_ldif(schema.schema_dn_add)
samdb.modify_ldif(schema.schema_dn_modify)
+ samdb.write_prefixes_from_schema()
samdb.add_ldif(schema.schema_data)
setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"),
{"SCHEMADN": names.schemadn})
diff --git a/source4/setup/provision_schema_basedn_modify.ldif b/source4/setup/provision_schema_basedn_modify.ldif
index ef883fcf22..5591f8bc36 100644
--- a/source4/setup/provision_schema_basedn_modify.ldif
+++ b/source4/setup/provision_schema_basedn_modify.ldif
@@ -6,7 +6,4 @@ changetype: modify
-
replace: objectVersion
objectVersion: 30
--
-replace: prefixMap
-prefixMap:: ${PREFIXMAP_B64}