s4:libcli/finddc.h - fix header dependancies
[metze/samba/wip.git] / source4 / libnet / py_net.c
1 /*
2    Unix SMB/CIFS implementation.
3    Samba utility functions
4    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008-2010
5    Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2009
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "lib/ldb/pyldb.h"
22 #include "includes.h"
23 #include "libnet.h"
24 #include "auth/credentials/pycredentials.h"
25 #include "libcli/security/security.h"
26 #include "lib/events/events.h"
27 #include "param/pyparam.h"
28 #include "auth/gensec/gensec.h"
29 #include "librpc/rpc/pyrpc_util.h"
30 #include "libcli/finddc.h"
31 #include "libcli/resolve/resolve.h"
32
33 typedef struct {
34         PyObject_HEAD
35         TALLOC_CTX *mem_ctx;
36         struct libnet_context *libnet_ctx;
37         struct tevent_context *ev;
38 } py_net_Object;
39
40 static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwargs)
41 {
42         struct libnet_Join r;
43         NTSTATUS status;
44         PyObject *result;
45         TALLOC_CTX *mem_ctx;
46         const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
47
48         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames), 
49                                          &r.in.domain_name, &r.in.netbios_name, 
50                                          &r.in.join_type, &r.in.level))
51                 return NULL;
52
53         mem_ctx = talloc_new(self->mem_ctx);
54         if (mem_ctx == NULL) {
55                 PyErr_NoMemory();
56                 return NULL;
57         }
58
59         status = libnet_Join(self->libnet_ctx, mem_ctx, &r);
60         if (NT_STATUS_IS_ERR(status)) {
61                 PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
62                 talloc_free(mem_ctx);
63                 return NULL;
64         }
65
66         result = Py_BuildValue("sss", r.out.join_password,
67                                dom_sid_string(mem_ctx, r.out.domain_sid),
68                                r.out.domain_name);
69
70         talloc_free(mem_ctx);
71
72         return result;
73 }
74
75 static const char py_net_join_doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \
76 "Join the domain with the specified name.";
77
78 static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObject *kwargs)
79 {
80         union libnet_SetPassword r;
81         NTSTATUS status;
82         PyObject *py_creds;
83         TALLOC_CTX *mem_ctx;
84         struct tevent_context *ev;
85         const char *kwnames[] = { "account_name", "domain_name", "newpassword", "credentials", NULL };
86
87         r.generic.level = LIBNET_SET_PASSWORD_GENERIC;
88
89         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssO:set_password", discard_const_p(char *, kwnames),
90                                          &r.generic.in.account_name, &r.generic.in.domain_name,
91                                          &r.generic.in.newpassword, &py_creds)) {
92                 return NULL;
93         }
94
95         /* FIXME: we really need to get a context from the caller or we may end
96          * up with 2 event contexts */
97         ev = s4_event_context_init(NULL);
98
99         mem_ctx = talloc_new(ev);
100         if (mem_ctx == NULL) {
101                 PyErr_NoMemory();
102                 return NULL;
103         }
104
105         status = libnet_SetPassword(self->libnet_ctx, mem_ctx, &r);
106         if (NT_STATUS_IS_ERR(status)) {
107                 PyErr_SetString(PyExc_RuntimeError,
108                                 r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status));
109                 talloc_free(mem_ctx);
110                 return NULL;
111         }
112
113         talloc_free(mem_ctx);
114
115         Py_RETURN_NONE;
116 }
117
118 static const char py_net_set_password_doc[] = "set_password(account_name, domain_name, newpassword) -> True\n\n" \
119 "Set password for a user. You must supply credential with enough rights to do this.\n\n" \
120 "Sample usage is:\n" \
121 "net.set_password(account_name=<account_name>,\n" \
122 "                domain_name=domain_name,\n" \
123 "                newpassword=new_pass)\n";
124
125
126 static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObject *kwargs)
127 {
128         struct libnet_export_keytab r;
129         TALLOC_CTX *mem_ctx;
130         const char *kwnames[] = { "keytab", NULL };
131         NTSTATUS status;
132
133         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:export_keytab", discard_const_p(char *, kwnames),
134                                          &r.in.keytab_name)) {
135                 return NULL;
136         }
137
138         mem_ctx = talloc_new(self->mem_ctx);
139         if (mem_ctx == NULL) {
140                 PyErr_NoMemory();
141                 return NULL;
142         }
143
144         status = libnet_export_keytab(self->libnet_ctx, mem_ctx, &r);
145         if (NT_STATUS_IS_ERR(status)) {
146                 PyErr_SetString(PyExc_RuntimeError,
147                                 r.out.error_string?r.out.error_string:nt_errstr(status));
148                 talloc_free(mem_ctx);
149                 return NULL;
150         }
151
152         talloc_free(mem_ctx);
153
154         Py_RETURN_NONE;
155 }
156
157 static const char py_net_export_keytab_doc[] = "export_keytab(keytab, name)\n\n"
158 "Export the DC keytab to a keytab file.";
159
160 static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwargs)
161 {
162         const char *kwnames[] = { "server_name", NULL };
163         union libnet_RemoteTOD r;
164         NTSTATUS status;
165         TALLOC_CTX *mem_ctx;
166         char timestr[64];
167         PyObject *ret;
168         struct tm *tm;
169
170         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s",
171                 discard_const_p(char *, kwnames), &r.generic.in.server_name))
172                 return NULL;
173
174         r.generic.level                 = LIBNET_REMOTE_TOD_GENERIC;
175
176         mem_ctx = talloc_new(NULL);
177         if (mem_ctx == NULL) {
178                 PyErr_NoMemory();
179                 return NULL;
180         }
181
182         status = libnet_RemoteTOD(self->libnet_ctx, mem_ctx, &r);
183         if (!NT_STATUS_IS_OK(status)) {
184                 PyErr_SetString(PyExc_RuntimeError,
185                                 r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status));
186                 talloc_free(mem_ctx);
187                 return NULL;
188         }
189
190         ZERO_STRUCT(timestr);
191         tm = localtime(&r.generic.out.time);
192         strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);
193         
194         ret = PyString_FromString(timestr);
195
196         talloc_free(mem_ctx);
197
198         return ret;
199 }
200
201 static const char py_net_time_doc[] = "time(server_name) -> timestr\n"
202 "Retrieve the remote time on a server";
203
204 static PyObject *py_net_user_create(py_net_Object *self, PyObject *args, PyObject *kwargs)
205 {
206         const char *kwnames[] = { "username", NULL };
207         NTSTATUS status;
208         TALLOC_CTX *mem_ctx;
209         struct libnet_CreateUser r;
210
211         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", discard_const_p(char *, kwnames), 
212                                                                          &r.in.user_name))
213                 return NULL;
214
215         r.in.domain_name = cli_credentials_get_domain(self->libnet_ctx->cred);
216
217         mem_ctx = talloc_new(NULL);
218         if (mem_ctx == NULL) {
219                 PyErr_NoMemory();
220                 return NULL;
221         }
222
223         status = libnet_CreateUser(self->libnet_ctx, mem_ctx, &r);
224         if (!NT_STATUS_IS_OK(status)) {
225                 PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
226                 talloc_free(mem_ctx);
227                 return NULL;
228         }
229
230         talloc_free(mem_ctx);
231         
232         Py_RETURN_NONE;
233 }
234
235 static const char py_net_create_user_doc[] = "create_user(username)\n"
236 "Create a new user.";
237
238 static PyObject *py_net_user_delete(py_net_Object *self, PyObject *args, PyObject *kwargs)
239 {
240         const char *kwnames[] = { "username", NULL };
241         NTSTATUS status;
242         TALLOC_CTX *mem_ctx;
243         struct libnet_DeleteUser r;
244
245         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", discard_const_p(char *, kwnames), 
246                                                                          &r.in.user_name))
247                 return NULL;
248
249         r.in.domain_name = cli_credentials_get_domain(self->libnet_ctx->cred);
250
251         mem_ctx = talloc_new(NULL);
252         if (mem_ctx == NULL) {
253                 PyErr_NoMemory();
254                 return NULL;
255         }
256
257         status = libnet_DeleteUser(self->libnet_ctx, mem_ctx, &r);
258         if (!NT_STATUS_IS_OK(status)) {
259                 PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
260                 talloc_free(mem_ctx);
261                 return NULL;
262         }
263
264         talloc_free(mem_ctx);
265         
266         Py_RETURN_NONE;
267 }
268
269 static const char py_net_delete_user_doc[] = "delete_user(username)\n"
270 "Delete a user.";
271
272 static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
273 {
274         PyObject *mod_security, *dom_sid_Type;
275
276         mod_security = PyImport_ImportModule("samba.dcerpc.security");
277         if (mod_security == NULL)
278                 return NULL;
279
280         dom_sid_Type = PyObject_GetAttrString(mod_security, "dom_sid");
281         if (dom_sid_Type == NULL)
282                 return NULL;
283
284         return py_talloc_reference((PyTypeObject *)dom_sid_Type, sid);
285 }
286
287 static PyObject *py_net_vampire(py_net_Object *self, PyObject *args, PyObject *kwargs)
288 {
289         const char *kwnames[] = { "domain", "target_dir", NULL };
290         NTSTATUS status;
291         TALLOC_CTX *mem_ctx;
292         PyObject *ret;
293         struct libnet_Vampire r;
294
295         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z", discard_const_p(char *, kwnames),
296                                          &r.in.domain_name, &r.in.targetdir)) {
297                 return NULL;
298         }
299
300         r.in.netbios_name  = lpcfg_netbios_name(self->libnet_ctx->lp_ctx);
301         r.out.error_string = NULL;
302
303         mem_ctx = talloc_new(NULL);
304         if (mem_ctx == NULL) {
305                 PyErr_NoMemory();
306                 return NULL;
307         }
308
309         status = libnet_Vampire(self->libnet_ctx, mem_ctx, &r);
310
311         if (!NT_STATUS_IS_OK(status)) {
312                 PyErr_SetString(PyExc_RuntimeError,
313                                 r.out.error_string ? r.out.error_string : nt_errstr(status));
314                 talloc_free(mem_ctx);
315                 return NULL;
316         }
317
318         ret = Py_BuildValue("(sO)", r.out.domain_name, py_dom_sid_FromSid(r.out.domain_sid));
319
320         talloc_free(mem_ctx);
321
322         return ret;
323 }
324
325 struct replicate_state {
326         void *vampire_state;
327         dcerpc_InterfaceObject *drs_pipe;
328         struct libnet_BecomeDC_StoreChunk chunk;
329         DATA_BLOB gensec_skey;
330         struct libnet_BecomeDC_Partition partition;
331         struct libnet_BecomeDC_Forest forest;
332         struct libnet_BecomeDC_DestDSA dest_dsa;
333 };
334
335 /*
336   setup for replicate_chunk() calls
337  */
338 static PyObject *py_net_replicate_init(py_net_Object *self, PyObject *args, PyObject *kwargs)
339 {
340         const char *kwnames[] = { "samdb", "lp", "drspipe", NULL };
341         PyObject *py_ldb, *py_lp, *py_drspipe;
342         struct ldb_context *samdb;
343         struct loadparm_context *lp;
344         struct replicate_state *s;
345         NTSTATUS status;
346
347         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO",
348                                          discard_const_p(char *, kwnames),
349                                          &py_ldb, &py_lp, &py_drspipe)) {
350                 return NULL;
351         }
352
353         s = talloc_zero(NULL, struct replicate_state);
354         if (!s) return NULL;
355
356         lp = lpcfg_from_py_object(s, py_lp);
357         if (lp == NULL) {
358                 PyErr_SetString(PyExc_TypeError, "Expected lp object");
359                 talloc_free(s);
360                 return NULL;
361         }
362
363         samdb = PyLdb_AsLdbContext(py_ldb);
364         if (samdb == NULL) {
365                 PyErr_SetString(PyExc_TypeError, "Expected ldb object");
366                 talloc_free(s);
367                 return NULL;
368         }
369
370         s->drs_pipe = (dcerpc_InterfaceObject *)(py_drspipe);
371
372         s->vampire_state = libnet_vampire_replicate_init(s, samdb, lp);
373         if (s->vampire_state == NULL) {
374                 PyErr_SetString(PyExc_TypeError, "Failed to initialise vampire_state");
375                 talloc_free(s);
376                 return NULL;
377         }
378
379         status = gensec_session_key(s->drs_pipe->pipe->conn->security_state.generic_state,
380                                     &s->gensec_skey);
381         if (!NT_STATUS_IS_OK(status)) {
382                 PyErr_Format(PyExc_RuntimeError, "Unable to get session key from drspipe: %s",
383                              nt_errstr(status));
384                 talloc_free(s);
385                 return NULL;
386         }
387
388         s->forest.dns_name = lpcfg_dnsdomain(lp);
389
390         s->chunk.gensec_skey = &s->gensec_skey;
391         s->chunk.partition = &s->partition;
392         s->chunk.forest = &s->forest;
393         s->chunk.dest_dsa = &s->dest_dsa;
394
395         return PyCObject_FromTallocPtr(s);
396 }
397
398
399 /*
400   process one replication chunk
401  */
402 static PyObject *py_net_replicate_chunk(py_net_Object *self, PyObject *args, PyObject *kwargs)
403 {
404         const char *kwnames[] = { "state", "level", "ctr", "schema", NULL };
405         PyObject *py_state, *py_ctr, *py_schema;
406         struct replicate_state *s;
407         unsigned level;
408         NTSTATUS (*chunk_handler)(void *private_data, const struct libnet_BecomeDC_StoreChunk *c);
409         NTSTATUS status;
410
411         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OIO|O",
412                                          discard_const_p(char *, kwnames),
413                                          &py_state, &level, &py_ctr, &py_schema)) {
414                 return NULL;
415         }
416
417         s = talloc_get_type(PyCObject_AsVoidPtr(py_state), struct replicate_state);
418         if (!s) {
419                 PyErr_SetString(PyExc_TypeError, "Expected replication_state");
420                 return NULL;
421         }
422
423         switch (level) {
424         case 1:
425                 if (!py_check_dcerpc_type(py_ctr, "samba.dcerpc.drsuapi", "DsGetNCChangesCtr1")) {
426                         return NULL;
427                 }
428                 s->chunk.ctr1                         = py_talloc_get_ptr(py_ctr);
429                 s->partition.nc                       = *s->chunk.ctr1->naming_context;
430                 s->partition.more_data                = s->chunk.ctr1->more_data;
431                 s->partition.source_dsa_guid          = s->chunk.ctr1->source_dsa_guid;
432                 s->partition.source_dsa_invocation_id = s->chunk.ctr1->source_dsa_invocation_id;
433                 s->partition.highwatermark            = s->chunk.ctr1->new_highwatermark;
434                 break;
435         case 6:
436                 if (!py_check_dcerpc_type(py_ctr, "samba.dcerpc.drsuapi", "DsGetNCChangesCtr6")) {
437                         return NULL;
438                 }
439                 s->chunk.ctr6                         = py_talloc_get_ptr(py_ctr);
440                 s->partition.nc                       = *s->chunk.ctr6->naming_context;
441                 s->partition.more_data                = s->chunk.ctr6->more_data;
442                 s->partition.source_dsa_guid          = s->chunk.ctr6->source_dsa_guid;
443                 s->partition.source_dsa_invocation_id = s->chunk.ctr6->source_dsa_invocation_id;
444                 s->partition.highwatermark            = s->chunk.ctr6->new_highwatermark;
445                 break;
446         default:
447                 PyErr_Format(PyExc_TypeError, "Bad level %u in replicate_chunk", level);
448                 return NULL;
449         }
450
451         chunk_handler = libnet_vampire_cb_store_chunk;
452         if (py_schema) {
453                 if (!PyBool_Check(py_schema)) {
454                         PyErr_SetString(PyExc_TypeError, "Expected boolean schema");
455                         return NULL;
456                 }
457                 if (py_schema == Py_True) {
458                         chunk_handler = libnet_vampire_cb_schema_chunk;
459                 }
460         }
461
462         s->chunk.ctr_level = level;
463
464         status = chunk_handler(s->vampire_state, &s->chunk);
465         if (!NT_STATUS_IS_OK(status)) {
466                 PyErr_Format(PyExc_TypeError, "Failed to process chunk: %s", nt_errstr(status));
467                 return NULL;
468         }
469
470         Py_RETURN_NONE;
471 }
472
473
474 /*
475   find a DC given a domain name and server type
476  */
477 static PyObject *py_net_finddc(py_net_Object *self, PyObject *args)
478 {
479         const char *domain_name;
480         unsigned server_type;
481         NTSTATUS status;
482         struct finddcs *io;
483         TALLOC_CTX *mem_ctx;
484         PyObject *ret;
485
486         if (!PyArg_ParseTuple(args, "sI", &domain_name, &server_type)) {
487                 return NULL;
488         }
489
490         mem_ctx = talloc_new(self->mem_ctx);
491
492         io = talloc_zero(mem_ctx, struct finddcs);
493         io->in.domain_name = domain_name;
494         io->in.minimum_dc_flags = server_type;
495
496         status = finddcs_cldap(io, io,
497                                lpcfg_resolve_context(self->libnet_ctx->lp_ctx), self->ev);
498         if (NT_STATUS_IS_ERR(status)) {
499                 PyErr_SetString(PyExc_RuntimeError, nt_errstr(status));
500                 talloc_free(mem_ctx);
501                 return NULL;
502         }
503
504         ret = py_return_ndr_struct("samba.dcerpc.nbt", "NETLOGON_SAM_LOGON_RESPONSE_EX",
505                                    io, &io->out.netlogon.data.nt5_ex);
506         talloc_free(mem_ctx);
507
508         return ret;
509 }
510
511
512 static const char py_net_vampire_doc[] = "vampire(domain, target_dir=None)\n"
513                                          "Vampire a domain.";
514
515 static const char py_net_replicate_init_doc[] = "replicate_init(samdb, lp, drspipe)\n"
516                                          "Setup for replicate_chunk calls.";
517
518 static const char py_net_replicate_chunk_doc[] = "replicate_chunk(state, level, ctr, schema)\n"
519                                          "Process replication for one chunk";
520
521 static const char py_net_finddc_doc[] = "finddc(domain, server_type)\n"
522                                          "find a DC with the specified server_type bits. Return the DNS name";
523
524 static PyMethodDef net_obj_methods[] = {
525         {"join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
526         {"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc},
527         {"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc},
528         {"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc},
529         {"create_user", (PyCFunction)py_net_user_create, METH_VARARGS|METH_KEYWORDS, py_net_create_user_doc},
530         {"delete_user", (PyCFunction)py_net_user_delete, METH_VARARGS|METH_KEYWORDS, py_net_delete_user_doc},
531         {"vampire", (PyCFunction)py_net_vampire, METH_VARARGS|METH_KEYWORDS, py_net_vampire_doc},
532         {"replicate_init", (PyCFunction)py_net_replicate_init, METH_VARARGS|METH_KEYWORDS, py_net_replicate_init_doc},
533         {"replicate_chunk", (PyCFunction)py_net_replicate_chunk, METH_VARARGS|METH_KEYWORDS, py_net_replicate_chunk_doc},
534         {"finddc", (PyCFunction)py_net_finddc, METH_VARARGS, py_net_finddc_doc},
535         { NULL }
536 };
537
538 static void py_net_dealloc(py_net_Object *self)
539 {
540         talloc_free(self->mem_ctx);
541 }
542
543 static PyObject *net_obj_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
544 {
545         PyObject *py_creds, *py_lp = Py_None;
546         const char *kwnames[] = { "creds", "lp", "server", NULL };
547         py_net_Object *ret;
548         struct loadparm_context *lp;
549         const char *server_address = NULL;
550
551         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oz",
552                                          discard_const_p(char *, kwnames), &py_creds, &py_lp,
553                                          &server_address))
554                 return NULL;
555
556         ret = PyObject_New(py_net_Object, type);
557         if (ret == NULL) {
558                 return NULL;
559         }
560
561         /* FIXME: we really need to get a context from the caller or we may end
562          * up with 2 event contexts */
563         ret->ev = s4_event_context_init(NULL);
564         ret->mem_ctx = talloc_new(ret->ev);
565
566         lp = lpcfg_from_py_object(ret->mem_ctx, py_lp);
567         if (lp == NULL) {
568                 Py_DECREF(ret);
569                 return NULL;
570         }
571
572         ret->libnet_ctx = libnet_context_init(ret->ev, lp);
573         if (ret->libnet_ctx == NULL) {
574                 PyErr_SetString(PyExc_RuntimeError, "Unable to initialize net");
575                 Py_DECREF(ret);
576                 return NULL;
577         }
578
579         ret->libnet_ctx->server_address = server_address;
580
581         ret->libnet_ctx->cred = cli_credentials_from_py_object(py_creds);
582         if (ret->libnet_ctx->cred == NULL) {
583                 PyErr_SetString(PyExc_TypeError, "Expected credentials object");
584                 Py_DECREF(ret);
585                 return NULL;
586         }
587
588         return (PyObject *)ret;
589 }
590
591
592 PyTypeObject py_net_Type = {
593         PyObject_HEAD_INIT(NULL) 0,
594         .tp_name = "net.Net",
595         .tp_basicsize = sizeof(py_net_Object),
596         .tp_dealloc = (destructor)py_net_dealloc,
597         .tp_methods = net_obj_methods,
598         .tp_new = net_obj_new,
599 };
600
601 void initnet(void)
602 {
603         PyObject *m;
604
605         if (PyType_Ready(&py_net_Type) < 0)
606                 return;
607
608         m = Py_InitModule3("net", NULL, NULL);
609         if (m == NULL)
610                 return;
611
612         Py_INCREF(&py_net_Type);
613         PyModule_AddObject(m, "Net", (PyObject *)&py_net_Type);
614         PyModule_AddObject(m, "LIBNET_JOINDOMAIN_AUTOMATIC", PyInt_FromLong(LIBNET_JOINDOMAIN_AUTOMATIC));
615         PyModule_AddObject(m, "LIBNET_JOINDOMAIN_SPECIFIED", PyInt_FromLong(LIBNET_JOINDOMAIN_SPECIFIED));
616         PyModule_AddObject(m, "LIBNET_JOIN_AUTOMATIC", PyInt_FromLong(LIBNET_JOIN_AUTOMATIC));
617         PyModule_AddObject(m, "LIBNET_JOIN_SPECIFIED", PyInt_FromLong(LIBNET_JOIN_SPECIFIED));
618 }