2 Python wrappers for DCERPC/SMB client routines.
4 Copyright (C) Tim Potter, 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "python/py_samr.h"
26 PyObject *new_samr_connect_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx,
29 samr_connect_hnd_object *o;
31 o = PyObject_New(samr_connect_hnd_object, &samr_connect_hnd_type);
35 memcpy(&o->pol, pol, sizeof(POLICY_HND));
41 * Exceptions raised by this module
44 PyObject *samr_error; /* This indicates a non-RPC related error
45 such as name lookup failure */
47 PyObject *samr_ntstatus; /* This exception is raised when a RPC call
48 returns a status code other than
51 static void py_samr_connect_hnd_dealloc(PyObject* self)
58 static PyObject *py_samr_connect_hnd_getattr(PyObject *self, char *attrname)
60 return Py_FindMethod(samr_connect_methods, self, attrname);
65 PyTypeObject samr_connect_hnd_type = {
66 PyObject_HEAD_INIT(NULL)
68 "SAMR Connect Handle",
69 sizeof(samr_connect_hnd_object),
71 py_samr_connect_hnd_dealloc, /*tp_dealloc*/
73 // py_samr_connect_hnd_getattr, /*tp_getattr*/
83 PyTypeObject samr_domain_hnd_type = {
84 PyObject_HEAD_INIT(NULL)
87 sizeof(samr_connect_hnd_object),
89 py_samr_connect_hnd_dealloc, /*tp_dealloc*/
91 // py_samr_connect_hnd_getattr, /*tp_getattr*/
101 PyTypeObject samr_user_hnd_type = {
102 PyObject_HEAD_INIT(NULL)
105 sizeof(samr_connect_hnd_object),
107 py_samr_connect_hnd_dealloc, /*tp_dealloc*/
109 // py_samr_connect_hnd_getattr, /*tp_getattr*/
114 0, /*tp_as_sequence*/
119 PyTypeObject samr_group_hnd_type = {
120 PyObject_HEAD_INIT(NULL)
123 sizeof(samr_connect_hnd_object),
125 py_samr_connect_hnd_dealloc, /*tp_dealloc*/
127 // py_samr_connect_hnd_getattr, /*tp_getattr*/
132 0, /*tp_as_sequence*/
137 PyTypeObject samr_alias_hnd_type = {
138 PyObject_HEAD_INIT(NULL)
141 sizeof(samr_connect_hnd_object),
143 py_samr_connect_hnd_dealloc, /*tp_dealloc*/
145 // py_samr_connect_hnd_getattr, /*tp_getattr*/
150 0, /*tp_as_sequence*/
155 static PyMethodDef samr_methods[] = {
157 /* Open/close samr connect handles */
160 { "connect", lsa_open_policy, METH_VARARGS | METH_KEYWORDS,
161 "Open a connect handle" },
163 { "close", lsa_close, METH_VARARGS, "Close a policy handle" },
170 * Module initialisation
175 PyObject *module, *dict;
177 /* Initialise module */
179 module = Py_InitModule("samr", samr_methods);
180 dict = PyModule_GetDict(module);
182 samr_error = PyErr_NewException("samr.error", NULL, NULL);
183 PyDict_SetItemString(dict, "error", samr_error);
185 samr_ntstatus = PyErr_NewException("samr.ntstatus", NULL, NULL);
186 PyDict_SetItemString(dict, "ntstatus", samr_ntstatus);
188 /* Initialise policy handle object */
190 samr_connect_hnd_type.ob_type = &PyType_Type;
191 samr_domain_hnd_type.ob_type = &PyType_Type;
192 samr_user_hnd_type.ob_type = &PyType_Type;
193 samr_group_hnd_type.ob_type = &PyType_Type;
194 samr_alias_hnd_type.ob_type = &PyType_Type;
196 /* Initialise constants */
200 /* Do samba initialisation */
204 setup_logging("samr", True);