summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-05-06 11:16:27 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-20 17:19:11 +0200
commit60bc5fe0ed1aae43c3931eae2a765dae765c85e5 (patch)
tree5226acc415ea0ed9adfb55e1d14a619528e964c3 /source4
parent381e82465842c7d1195ca81db40a0c5d9f9e9c57 (diff)
downloadsamba-60bc5fe0ed1aae43c3931eae2a765dae765c85e5.tar.gz
samba-60bc5fe0ed1aae43c3931eae2a765dae765c85e5.tar.bz2
samba-60bc5fe0ed1aae43c3931eae2a765dae765c85e5.zip
samba4: Add python bindings for samba.policy.get_gplink_options.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/policy/pypolicy.c48
-rw-r--r--source4/lib/policy/tests/python/bindings.py4
2 files changed, 52 insertions, 0 deletions
diff --git a/source4/lib/policy/pypolicy.c b/source4/lib/policy/pypolicy.c
index 5389a09200..9ace387a80 100644
--- a/source4/lib/policy/pypolicy.c
+++ b/source4/lib/policy/pypolicy.c
@@ -64,9 +64,53 @@ static PyObject *py_get_gpo_flags(PyObject *self, PyObject *args)
return py_ret;
}
+static PyObject *py_get_gplink_options(PyObject *self, PyObject *args)
+{
+ int flags;
+ PyObject *py_ret;
+ const char **ret;
+ TALLOC_CTX *mem_ctx;
+ int i;
+ NTSTATUS status;
+
+ if (!PyArg_ParseTuple(args, "i", &flags))
+ return NULL;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ status = gp_get_gplink_options(mem_ctx, flags, &ret);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetNTSTATUS(status);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ py_ret = PyList_New(0);
+ for (i = 0; ret[i]; i++) {
+ PyObject *item = PyString_FromString(ret[i]);
+ if (item == NULL) {
+ talloc_free(mem_ctx);
+ Py_DECREF(py_ret);
+ PyErr_NoMemory();
+ return NULL;
+ }
+ PyList_Append(py_ret, item);
+ }
+
+ talloc_free(mem_ctx);
+
+ return py_ret;
+}
+
static PyMethodDef py_policy_methods[] = {
{ "get_gpo_flags", (PyCFunction)py_get_gpo_flags, METH_VARARGS,
"get_gpo_flags(flags) -> list" },
+ { "get_gplink_options", (PyCFunction)py_get_gplink_options, METH_VARARGS,
+ "get_gplink_options(options) -> list" },
{ NULL }
};
@@ -82,4 +126,8 @@ void initpolicy(void)
PyInt_FromLong(GPO_FLAG_USER_DISABLE));
PyModule_AddObject(m, "GPO_MACHINE_USER_DISABLE",
PyInt_FromLong(GPO_FLAG_MACHINE_DISABLE));
+ PyModule_AddObject(m, "GPLINK_OPT_DISABLE",
+ PyInt_FromLong(GPLINK_OPT_DISABLE ));
+ PyModule_AddObject(m, "GPLINK_OPT_ENFORCE ",
+ PyInt_FromLong(GPLINK_OPT_ENFORCE ));
}
diff --git a/source4/lib/policy/tests/python/bindings.py b/source4/lib/policy/tests/python/bindings.py
index 1a698f16e0..0d6a63bf75 100644
--- a/source4/lib/policy/tests/python/bindings.py
+++ b/source4/lib/policy/tests/python/bindings.py
@@ -29,3 +29,7 @@ class PolicyTests(unittest.TestCase):
def test_get_gpo_flags(self):
self.assertEquals(["GPO_FLAG_USER_DISABLE"],
policy.get_gpo_flags(policy.GPO_FLAG_USER_DISABLE))
+
+ def test_get_gplink_options(self):
+ self.assertEquals(["GPLINK_OPT_DISABLE"],
+ policy.get_gplink_options(policy.GPLINK_OPT_DISABLE))