Py_RETURN_NONE;
}
+static PyObject *py_samdb_set_ntds_settings_dn(PyLdbObject *self, PyObject *args)
+{
+ PyObject *py_ldb, *py_ntds_settings_dn;
+ struct ldb_context *ldb;
+ struct ldb_dn *ntds_settings_dn;
+ TALLOC_CTX *tmp_ctx;
+ bool ret;
+
+ if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_ntds_settings_dn))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ if (!PyObject_AsDn(tmp_ctx, py_ntds_settings_dn, ldb, &ntds_settings_dn)) {
+ return NULL;
+ }
+
+ ret = samdb_set_ntds_settings_dn(ldb, ntds_settings_dn);
+ talloc_free(tmp_ctx);
+ if (!ret) {
+ PyErr_SetString(PyExc_RuntimeError, "set_ntds_settings_dn failed");
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args)
{
PyObject *py_ldb;
uint32_t attid;
struct dsdb_schema *schema;
const char *oid;
+ PyObject *ret;
TALLOC_CTX *mem_ctx;
WERROR status;
+ if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
+ return NULL;
+
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
- if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
- return NULL;
-
PyErr_LDB_OR_RAISE(py_ldb, ldb);
schema = dsdb_get_schema(ldb, NULL);
if (!schema) {
PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n");
+ talloc_free(mem_ctx);
return NULL;
}
- status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid,
- mem_ctx, &oid);
+
+ status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid,
+ mem_ctx, &oid);
PyErr_WERROR_IS_ERR_RAISE(status);
- return PyString_FromString(oid);
+ ret = PyString_FromString(oid);
+
+ talloc_free(mem_ctx);
+
+ return ret;
}
static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
return result;
}
+static PyObject *py_dsdb_set_am_rodc(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb;
+ bool ret;
+ struct ldb_context *ldb;
+ int py_val;
+
+ if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &py_val))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+ ret = samdb_set_am_rodc(ldb, (bool)py_val);
+ if (!ret) {
+ PyErr_SetString(PyExc_RuntimeError, "set_am_rodc failed");
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *py_dsdb_set_schema_from_ldif(PyObject *self, PyObject *args)
+{
+ WERROR result;
+ char *pf, *df;
+ PyObject *py_ldb;
+ struct ldb_context *ldb;
+
+ if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &pf, &df))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ result = dsdb_set_schema_from_ldif(ldb, pf, df);
+ PyErr_WERROR_IS_ERR_RAISE(result);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb;
+ struct ldb_context *ldb;
+ PyObject *py_from_ldb;
+ struct ldb_context *from_ldb;
+ struct dsdb_schema *schema;
+ int ret;
+ if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_from_ldb))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ PyErr_LDB_OR_RAISE(py_from_ldb, from_ldb);
+
+ schema = dsdb_get_schema(from_ldb, NULL);
+ if (!schema) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on 'from' ldb!\n");
+ return NULL;
+ }
+
+ ret = dsdb_reference_schema(ldb, schema, true);
+ PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
+
+ Py_RETURN_NONE;
+}
+
+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, NULL);
+ 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 PyMethodDef py_dsdb_methods[] = {
- { "samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
+ { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
METH_VARARGS, "Get the server site name as a string"},
- { "dsdb_convert_schema_to_openldap",
+ { "_dsdb_convert_schema_to_openldap",
(PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
"dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
"Create an OpenLDAP schema from a schema." },
- { "samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid,
+ { "_samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid,
METH_VARARGS,
"samdb_set_domain_sid(samdb, sid)\n"
"Set SID of domain to use." },
- { "samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid,
+ { "_samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid,
METH_VARARGS,
"samdb_get_domain_sid(samdb)\n"
"Get SID of domain in use." },
- { "samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id,
+ { "_samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id,
METH_VARARGS, "get the NTDS invocation ID GUID as a string"},
- { "dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, METH_VARARGS,
- NULL },
- { "dsdb_set_ntds_invocation_id",
+ { "_samdb_set_ntds_settings_dn", (PyCFunction)py_samdb_set_ntds_settings_dn,
+ METH_VARARGS,
+ "samdb_set_ntds_settings_dn(samdb, ntds_settings_dn)\n"
+ "Set NTDS Settings DN for this LDB (allows it to be set before the DB fully exists)." },
+ { "_dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid,
+ METH_VARARGS, NULL },
+ { "_dsdb_set_ntds_invocation_id",
(PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS,
NULL },
- { "samdb_ntds_objectGUID", (PyCFunction)py_samdb_ntds_objectGUID,
+ { "_samdb_ntds_objectGUID", (PyCFunction)py_samdb_ntds_objectGUID,
METH_VARARGS, "get the NTDS objectGUID as a string"},
- { "dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
+ { "_dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
METH_VARARGS, NULL },
- { "dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
+ { "_dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
METH_VARARGS,
"get uSNHighest and uSNUrgent from the partition @REPLCHANGED"},
+ { "_dsdb_set_am_rodc",
+ (PyCFunction)py_dsdb_set_am_rodc, METH_VARARGS,
+ NULL },
+ { "_dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS,
+ NULL },
+ { "_dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
+ NULL },
+ { "_dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
+ NULL },
{ NULL }
};
PyInt_FromLong(DS_DOMAIN_FUNCTION_2008));
PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008_R2",
PyInt_FromLong(DS_DOMAIN_FUNCTION_2008_R2));
-
- /* "domainControllerFunctionality" flags in the rootDSE */
- PyModule_AddObject(m, "DS_DC_FUNCTION_2000",
- PyInt_FromLong(DS_DC_FUNCTION_2000));
- PyModule_AddObject(m, "DS_DC_FUNCTION_2003",
- PyInt_FromLong(DS_DC_FUNCTION_2003));
- PyModule_AddObject(m, "DS_DC_FUNCTION_2008",
- PyInt_FromLong(DS_DC_FUNCTION_2008));
- PyModule_AddObject(m, "DS_DC_FUNCTION_2008_R2",
- PyInt_FromLong(DS_DC_FUNCTION_2008_R2));
}