HP2500C driver writes devmode with private data that ends
[kai/samba-autobuild/.git] / source / python / py_lsa.c
1 #include "includes.h"
2 #include "Python.h"
3 #include "python/py_common.h"
4
5 static void py_policy_hnd_dealloc(PyObject* self)
6 {
7         PyObject_Del(self);
8 }
9
10 typedef struct {
11         PyObject_HEAD
12         struct cli_state *cli;
13         TALLOC_CTX *mem_ctx;
14         POLICY_HND pol;
15 } lsa_policy_hnd_object;
16
17 PyTypeObject lsa_policy_hnd_type = {
18         PyObject_HEAD_INIT(NULL)
19         0,
20         "LSA Policy Handle",
21         sizeof(lsa_policy_hnd_object),
22         0,
23         py_policy_hnd_dealloc, /*tp_dealloc*/
24         0,          /*tp_print*/
25         0,          /*tp_getattr*/
26         0,          /*tp_setattr*/
27         0,          /*tp_compare*/
28         0,          /*tp_repr*/
29         0,          /*tp_as_number*/
30         0,          /*tp_as_sequence*/
31         0,          /*tp_as_mapping*/
32         0,          /*tp_hash */
33 };
34
35 /* 
36  * Exceptions raised by this module 
37  */
38
39 PyObject *lsa_error;            /* This indicates a non-RPC related error
40                                    such as name lookup failure */
41
42 PyObject *lsa_ntstatus;         /* This exception is raised when a RPC call
43                                    returns a status code other than
44                                    NT_STATUS_OK */
45
46 /*
47  * Open/close lsa handles
48  */
49
50 static PyObject *lsa_openpolicy(PyObject *self, PyObject *args, 
51                                 PyObject *kw) 
52 {
53         static char *kwlist[] = { "servername", "creds", "access", NULL };
54         char *server_name;
55         PyObject *creds = NULL;
56         uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
57
58         if (!PyArg_ParseTupleAndKeywords(
59                 args, kw, "s|O!i", kwlist, &server_name, &PyDict_Type,
60                 &creds, &desired_access)) {
61
62                 goto done;
63         }
64
65  done:
66         return NULL;
67 }
68
69 static PyObject *lsa_close(PyObject *self, PyObject *args, PyObject *kw) 
70 {
71         return NULL;
72 }
73
74 static PyObject *lsa_lookupnames(PyObject *self, PyObject *args, 
75                                  PyObject *kw) 
76 {
77         return NULL;
78 }
79
80 static PyObject *lsa_lookupsids(PyObject *self, PyObject *args, 
81                                 PyObject *kw) 
82 {
83         return NULL;
84 }
85
86 /*
87  * Method dispatch table
88  */
89
90 static PyMethodDef lsa_methods[] = {
91
92         /* Open/close lsa handles */
93         
94         { "openpolicy", lsa_openpolicy, METH_VARARGS | METH_KEYWORDS, 
95           "Open a policy handle" },
96         
97         { "close", lsa_close, METH_VARARGS, 
98           "Close a policy handle" },
99
100         /* Name <-> SID resolution */
101
102         { "lookupnames", lsa_lookupnames, METH_VARARGS | METH_KEYWORDS,
103           "Look up SIDS from a list of names" },
104
105         { "lookupsids", lsa_lookupsids, METH_VARARGS | METH_KEYWORDS,
106           "Look up names from a list of SIDS" },
107
108         { NULL }
109 };
110
111 /*
112  * Module initialisation 
113 */
114
115 void initlsa(void)
116 {
117         PyObject *module, *dict;
118
119         /* Initialise module */
120
121         module = Py_InitModule("lsa", lsa_methods);
122         dict = PyModule_GetDict(module);
123
124         lsa_error = PyErr_NewException("lsa.error", NULL, NULL);
125         PyDict_SetItemString(dict, "error", lsa_error);
126
127         lsa_ntstatus = PyErr_NewException("lsa.ntstatus", NULL, NULL);
128         PyDict_SetItemString(dict, "ntstatus", lsa_ntstatus);
129
130         /* Initialise policy handle object */
131
132         lsa_policy_hnd_type.ob_type = &PyType_Type;
133
134         /* Initialise constants */
135
136 //      const_init(dict);
137
138         /* Do samba initialisation */
139
140         py_samba_init();
141 }