mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
s4:provison Add prefixes to ldb using same code a later modify will use
This allows us to test out the code that will do the modify of the prefixMap, and to provide the bindings that may assist a future upgrade script. Andrew Bartlett
This commit is contained in:
@ -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,
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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})
|
||||
|
@ -6,7 +6,4 @@ changetype: modify
|
||||
-
|
||||
replace: objectVersion
|
||||
objectVersion: 30
|
||||
-
|
||||
replace: prefixMap
|
||||
prefixMap:: ${PREFIXMAP_B64}
|
||||
|
||||
|
Reference in New Issue
Block a user