From: Stefan Metzmacher Date: Tue, 18 Jul 2023 15:17:21 +0000 (+0200) Subject: s4:pydsdb: add dc_operatingSystemVersion() helper X-Git-Tag: talloc-2.4.1~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a79bed41e205823e7eed58a30ade1f40441a22e;p=thirdparty%2Fsamba.git s4:pydsdb: add dc_operatingSystemVersion() helper Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 22506423d49..6bf304f4f91 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -1458,6 +1458,25 @@ static PyObject *py_dsdb_check_and_update_fl(PyObject *self, PyObject *args) Py_RETURN_NONE; } +static PyObject *py_dsdb_dc_operatingSystemVersion(PyObject *self, PyObject *args) +{ + const char *str = NULL; + int dc_level = 0; + + if (!PyArg_ParseTuple(args, "i", &dc_level)) { + return NULL; + } + + str = dsdb_dc_operatingSystemVersion(dc_level); + if (str == NULL) { + return PyErr_Format(PyExc_KeyError, + "dsdb_dc_operatingSystemVersion(%d) failed", + dc_level); + } + + return PyUnicode_FromString(str); +} + static PyMethodDef py_dsdb_methods[] = { { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name, METH_VARARGS, "Get the server site name as a string"}, @@ -1550,6 +1569,11 @@ static PyMethodDef py_dsdb_methods[] = { "check_and_update_fl(ldb, lp) -> None\n" "Hook to run in testing the code run on samba server startup " "to validate and update DC functional levels"}, + { "dc_operatingSystemVersion", + (PyCFunction)py_dsdb_dc_operatingSystemVersion, + METH_VARARGS, + "dsdb_dc_operatingSystemVersion(dc_level)" + " -> string name" }, {0} };