2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "param/param.h"
24 #include "libcli/security/security.h"
26 struct libnet_context *py_net_ctx(PyObject *obj)
29 return libnet_context_init(NULL, global_loadparm);
32 static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
38 struct libnet_context *libnet_ctx;
39 const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
41 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames),
42 &r.in.domain_name, &r.in.netbios_name,
43 &r.in.join_type, &r.in.level))
46 mem_ctx = talloc_new(NULL);
48 libnet_ctx = py_net_ctx(cls);
50 status = libnet_Join(libnet_ctx, mem_ctx, &r);
51 if (NT_STATUS_IS_ERR(status)) {
52 PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
57 result = Py_BuildValue("sss", r.out.join_password,
58 dom_sid_string(mem_ctx, r.out.domain_sid),
69 static struct PyMethodDef net_methods[] = {
70 {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS},
76 Py_InitModule("net", net_methods);