3 #include "python/py_common.h"
5 static void py_policy_hnd_dealloc(PyObject* self)
12 struct cli_state *cli;
15 } lsa_policy_hnd_object;
17 PyTypeObject lsa_policy_hnd_type = {
18 PyObject_HEAD_INIT(NULL)
21 sizeof(lsa_policy_hnd_object),
23 py_policy_hnd_dealloc, /*tp_dealloc*/
36 * Exceptions raised by this module
39 PyObject *lsa_error; /* This indicates a non-RPC related error
40 such as name lookup failure */
42 PyObject *lsa_ntstatus; /* This exception is raised when a RPC call
43 returns a status code other than
47 * Open/close lsa handles
50 static PyObject *lsa_openpolicy(PyObject *self, PyObject *args,
53 static char *kwlist[] = { "servername", "creds", "access", NULL };
55 PyObject *creds = NULL;
56 uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
58 if (!PyArg_ParseTupleAndKeywords(
59 args, kw, "s|O!i", kwlist, &server_name, &PyDict_Type,
60 &creds, &desired_access)) {
69 static PyObject *lsa_close(PyObject *self, PyObject *args, PyObject *kw)
74 static PyObject *lsa_lookupnames(PyObject *self, PyObject *args,
80 static PyObject *lsa_lookupsids(PyObject *self, PyObject *args,
87 * Method dispatch table
90 static PyMethodDef lsa_methods[] = {
92 /* Open/close lsa handles */
94 { "openpolicy", lsa_openpolicy, METH_VARARGS | METH_KEYWORDS,
95 "Open a policy handle" },
97 { "close", lsa_close, METH_VARARGS,
98 "Close a policy handle" },
100 /* Name <-> SID resolution */
102 { "lookupnames", lsa_lookupnames, METH_VARARGS | METH_KEYWORDS,
103 "Look up SIDS from a list of names" },
105 { "lookupsids", lsa_lookupsids, METH_VARARGS | METH_KEYWORDS,
106 "Look up names from a list of SIDS" },
112 * Module initialisation
117 PyObject *module, *dict;
119 /* Initialise module */
121 module = Py_InitModule("lsa", lsa_methods);
122 dict = PyModule_GetDict(module);
124 lsa_error = PyErr_NewException("lsa.error", NULL, NULL);
125 PyDict_SetItemString(dict, "error", lsa_error);
127 lsa_ntstatus = PyErr_NewException("lsa.ntstatus", NULL, NULL);
128 PyDict_SetItemString(dict, "ntstatus", lsa_ntstatus);
130 /* Initialise policy handle object */
132 lsa_policy_hnd_type.ob_type = &PyType_Type;
134 /* Initialise constants */
138 /* Do samba initialisation */