2 Unix SMB/CIFS implementation.
3 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "python/py3compat.h"
22 #include "python/modules.h"
23 #include "pycredentials.h"
24 #include "param/param.h"
25 #include "auth/credentials/credentials_internal.h"
26 #include "librpc/gen_ndr/samr.h" /* for struct samr_Password */
27 #include "librpc/gen_ndr/netlogon.h"
28 #include "libcli/util/pyerrors.h"
29 #include "libcli/auth/libcli_auth.h"
30 #include "param/pyparam.h"
32 #include "libcli/auth/libcli_auth.h"
33 #include "system/kerberos.h"
34 #include "auth/kerberos/kerberos.h"
35 #include "libcli/smb/smb_constants.h"
37 void initcredentials(void);
39 static PyObject
*py_creds_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwargs
)
41 return pytalloc_steal(type
, cli_credentials_init(NULL
));
44 static PyObject
*py_creds_get_username(PyObject
*self
, PyObject
*unused
)
46 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
48 PyErr_Format(PyExc_TypeError
, "Credentials expected");
51 return PyString_FromStringOrNULL(cli_credentials_get_username(creds
));
54 static PyObject
*py_creds_set_username(PyObject
*self
, PyObject
*args
)
57 enum credentials_obtained obt
= CRED_SPECIFIED
;
59 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
61 PyErr_Format(PyExc_TypeError
, "Credentials expected");
65 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
70 return PyBool_FromLong(cli_credentials_set_username(creds
, newval
, obt
));
73 static PyObject
*py_creds_get_ntlm_username_domain(PyObject
*self
, PyObject
*unused
)
75 TALLOC_CTX
*frame
= talloc_stackframe();
76 const char *user
= NULL
;
77 const char *domain
= NULL
;
79 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
81 PyErr_Format(PyExc_TypeError
, "Credentials expected");
84 cli_credentials_get_ntlm_username_domain(creds
,
85 frame
, &user
, &domain
);
86 ret
= Py_BuildValue("(ss)",
94 static PyObject
*py_creds_get_ntlm_response(PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
96 TALLOC_CTX
*frame
= talloc_stackframe();
99 struct timeval tv_now
;
100 NTTIME server_timestamp
;
101 DATA_BLOB challenge
= data_blob_null
;
102 DATA_BLOB target_info
= data_blob_null
;
104 DATA_BLOB lm_response
= data_blob_null
;
105 DATA_BLOB nt_response
= data_blob_null
;
106 DATA_BLOB lm_session_key
= data_blob_null
;
107 DATA_BLOB nt_session_key
= data_blob_null
;
108 const char *kwnames
[] = { "flags", "challenge",
111 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
113 PyErr_Format(PyExc_TypeError
, "Credentials expected");
117 tv_now
= timeval_current();
118 server_timestamp
= timeval_to_nttime(&tv_now
);
120 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "is#|s#",
121 discard_const_p(char *, kwnames
),
126 &target_info
.length
)) {
130 status
= cli_credentials_get_ntlm_response(creds
,
135 &lm_response
, &nt_response
,
136 &lm_session_key
, &nt_session_key
);
138 if (!NT_STATUS_IS_OK(status
)) {
139 PyErr_SetNTSTATUS(status
);
144 ret
= Py_BuildValue("{sis" PYARG_BYTES_LEN
"s" PYARG_BYTES_LEN
145 "s" PYARG_BYTES_LEN
"s" PYARG_BYTES_LEN
"}",
148 (const char *)lm_response
.data
, lm_response
.length
,
150 (const char *)nt_response
.data
, nt_response
.length
,
152 (const char *)lm_session_key
.data
, lm_session_key
.length
,
154 (const char *)nt_session_key
.data
, nt_session_key
.length
);
159 static PyObject
*py_creds_get_principal(PyObject
*self
, PyObject
*unused
)
161 TALLOC_CTX
*frame
= talloc_stackframe();
162 PyObject
*ret
= NULL
;
163 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
165 PyErr_Format(PyExc_TypeError
, "Credentials expected");
168 ret
= PyString_FromStringOrNULL(cli_credentials_get_principal(creds
, frame
));
173 static PyObject
*py_creds_set_principal(PyObject
*self
, PyObject
*args
)
176 enum credentials_obtained obt
= CRED_SPECIFIED
;
178 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
180 PyErr_Format(PyExc_TypeError
, "Credentials expected");
184 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
189 return PyBool_FromLong(cli_credentials_set_principal(creds
, newval
, obt
));
192 static PyObject
*py_creds_get_password(PyObject
*self
, PyObject
*unused
)
194 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
196 PyErr_Format(PyExc_TypeError
, "Credentials expected");
199 return PyString_FromStringOrNULL(cli_credentials_get_password(creds
));
202 static PyObject
*py_creds_set_password(PyObject
*self
, PyObject
*args
)
204 const char *newval
= NULL
;
205 enum credentials_obtained obt
= CRED_SPECIFIED
;
207 PyObject
*result
= NULL
;
208 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
210 PyErr_Format(PyExc_TypeError
, "Credentials expected");
214 if (!PyArg_ParseTuple(args
, PYARG_STR_UNI
"|i", "utf8", &newval
, &_obt
)) {
219 result
= PyBool_FromLong(cli_credentials_set_password(creds
, newval
, obt
));
220 PyMem_Free(discard_const_p(void*, newval
));
224 static PyObject
*py_creds_set_utf16_password(PyObject
*self
, PyObject
*args
)
226 enum credentials_obtained obt
= CRED_SPECIFIED
;
228 PyObject
*newval
= NULL
;
229 DATA_BLOB blob
= data_blob_null
;
233 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
235 PyErr_Format(PyExc_TypeError
, "Credentials expected");
239 if (!PyArg_ParseTuple(args
, "O|i", &newval
, &_obt
)) {
244 result
= PyBytes_AsStringAndSize(newval
, (char **)&blob
.data
, &size
);
246 PyErr_SetString(PyExc_RuntimeError
, "Failed to convert passed value to Bytes");
251 ok
= cli_credentials_set_utf16_password(creds
,
254 return PyBool_FromLong(ok
);
257 static PyObject
*py_creds_get_old_password(PyObject
*self
, PyObject
*unused
)
259 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
261 PyErr_Format(PyExc_TypeError
, "Credentials expected");
264 return PyString_FromStringOrNULL(cli_credentials_get_old_password(creds
));
267 static PyObject
*py_creds_set_old_password(PyObject
*self
, PyObject
*args
)
270 enum credentials_obtained obt
= CRED_SPECIFIED
;
272 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
274 PyErr_Format(PyExc_TypeError
, "Credentials expected");
278 if (!PyArg_ParseTuple(args
, "s|i", &oldval
, &_obt
)) {
283 return PyBool_FromLong(cli_credentials_set_old_password(creds
, oldval
, obt
));
286 static PyObject
*py_creds_set_old_utf16_password(PyObject
*self
, PyObject
*args
)
288 PyObject
*oldval
= NULL
;
289 DATA_BLOB blob
= data_blob_null
;
293 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
295 PyErr_Format(PyExc_TypeError
, "Credentials expected");
299 if (!PyArg_ParseTuple(args
, "O", &oldval
)) {
303 result
= PyBytes_AsStringAndSize(oldval
, (char **)&blob
.data
, &size
);
305 PyErr_SetString(PyExc_RuntimeError
, "Failed to convert passed value to Bytes");
310 ok
= cli_credentials_set_old_utf16_password(creds
,
313 return PyBool_FromLong(ok
);
316 static PyObject
*py_creds_get_domain(PyObject
*self
, PyObject
*unused
)
318 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
320 PyErr_Format(PyExc_TypeError
, "Credentials expected");
323 return PyString_FromStringOrNULL(cli_credentials_get_domain(creds
));
326 static PyObject
*py_creds_set_domain(PyObject
*self
, PyObject
*args
)
329 enum credentials_obtained obt
= CRED_SPECIFIED
;
331 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
333 PyErr_Format(PyExc_TypeError
, "Credentials expected");
337 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
342 return PyBool_FromLong(cli_credentials_set_domain(creds
, newval
, obt
));
345 static PyObject
*py_creds_get_realm(PyObject
*self
, PyObject
*unused
)
347 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
349 PyErr_Format(PyExc_TypeError
, "Credentials expected");
352 return PyString_FromStringOrNULL(cli_credentials_get_realm(creds
));
355 static PyObject
*py_creds_set_realm(PyObject
*self
, PyObject
*args
)
358 enum credentials_obtained obt
= CRED_SPECIFIED
;
360 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
362 PyErr_Format(PyExc_TypeError
, "Credentials expected");
366 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
371 return PyBool_FromLong(cli_credentials_set_realm(creds
, newval
, obt
));
374 static PyObject
*py_creds_get_bind_dn(PyObject
*self
, PyObject
*unused
)
376 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
378 PyErr_Format(PyExc_TypeError
, "Credentials expected");
381 return PyString_FromStringOrNULL(cli_credentials_get_bind_dn(creds
));
384 static PyObject
*py_creds_set_bind_dn(PyObject
*self
, PyObject
*args
)
387 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
389 PyErr_Format(PyExc_TypeError
, "Credentials expected");
392 if (!PyArg_ParseTuple(args
, "s", &newval
))
395 return PyBool_FromLong(cli_credentials_set_bind_dn(creds
, newval
));
398 static PyObject
*py_creds_get_workstation(PyObject
*self
, PyObject
*unused
)
400 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
402 PyErr_Format(PyExc_TypeError
, "Credentials expected");
405 return PyString_FromStringOrNULL(cli_credentials_get_workstation(creds
));
408 static PyObject
*py_creds_set_workstation(PyObject
*self
, PyObject
*args
)
411 enum credentials_obtained obt
= CRED_SPECIFIED
;
413 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
415 PyErr_Format(PyExc_TypeError
, "Credentials expected");
419 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
424 return PyBool_FromLong(cli_credentials_set_workstation(creds
, newval
, obt
));
427 static PyObject
*py_creds_is_anonymous(PyObject
*self
, PyObject
*unused
)
429 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
431 PyErr_Format(PyExc_TypeError
, "Credentials expected");
434 return PyBool_FromLong(cli_credentials_is_anonymous(creds
));
437 static PyObject
*py_creds_set_anonymous(PyObject
*self
, PyObject
*unused
)
439 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
441 PyErr_Format(PyExc_TypeError
, "Credentials expected");
444 cli_credentials_set_anonymous(creds
);
448 static PyObject
*py_creds_authentication_requested(PyObject
*self
, PyObject
*unused
)
450 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
452 PyErr_Format(PyExc_TypeError
, "Credentials expected");
455 return PyBool_FromLong(cli_credentials_authentication_requested(creds
));
458 static PyObject
*py_creds_wrong_password(PyObject
*self
, PyObject
*unused
)
460 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
462 PyErr_Format(PyExc_TypeError
, "Credentials expected");
465 return PyBool_FromLong(cli_credentials_wrong_password(creds
));
468 static PyObject
*py_creds_set_cmdline_callbacks(PyObject
*self
, PyObject
*unused
)
470 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
472 PyErr_Format(PyExc_TypeError
, "Credentials expected");
475 return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(creds
));
478 static PyObject
*py_creds_parse_string(PyObject
*self
, PyObject
*args
)
481 enum credentials_obtained obt
= CRED_SPECIFIED
;
483 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
485 PyErr_Format(PyExc_TypeError
, "Credentials expected");
489 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
494 cli_credentials_parse_string(creds
, newval
, obt
);
498 static PyObject
*py_creds_parse_file(PyObject
*self
, PyObject
*args
)
501 enum credentials_obtained obt
= CRED_SPECIFIED
;
503 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
505 PyErr_Format(PyExc_TypeError
, "Credentials expected");
509 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
514 cli_credentials_parse_file(creds
, newval
, obt
);
518 static PyObject
*py_cli_credentials_set_password_will_be_nt_hash(PyObject
*self
, PyObject
*args
)
520 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
521 PyObject
*py_val
= NULL
;
524 if (!PyArg_ParseTuple(args
, "O!", &PyBool_Type
, &py_val
)) {
527 val
= PyObject_IsTrue(py_val
);
529 cli_credentials_set_password_will_be_nt_hash(creds
, val
);
533 static PyObject
*py_creds_get_nt_hash(PyObject
*self
, PyObject
*unused
)
536 struct samr_Password
*ntpw
= NULL
;
537 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
539 PyErr_Format(PyExc_TypeError
, "Credentials expected");
542 ntpw
= cli_credentials_get_nt_hash(creds
, creds
);
544 ret
= PyBytes_FromStringAndSize(discard_const_p(char, ntpw
->hash
), 16);
549 static PyObject
*py_creds_get_kerberos_state(PyObject
*self
, PyObject
*unused
)
552 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
554 PyErr_Format(PyExc_TypeError
, "Credentials expected");
557 state
= cli_credentials_get_kerberos_state(creds
);
558 return PyLong_FromLong(state
);
561 static PyObject
*py_creds_set_kerberos_state(PyObject
*self
, PyObject
*args
)
564 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
566 PyErr_Format(PyExc_TypeError
, "Credentials expected");
569 if (!PyArg_ParseTuple(args
, "i", &state
))
572 cli_credentials_set_kerberos_state(creds
, state
, CRED_SPECIFIED
);
576 static PyObject
*py_creds_set_krb_forwardable(PyObject
*self
, PyObject
*args
)
579 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
581 PyErr_Format(PyExc_TypeError
, "Credentials expected");
584 if (!PyArg_ParseTuple(args
, "i", &state
))
587 cli_credentials_set_krb_forwardable(creds
, state
);
592 static PyObject
*py_creds_get_forced_sasl_mech(PyObject
*self
, PyObject
*unused
)
594 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
596 PyErr_Format(PyExc_TypeError
, "Credentials expected");
599 return PyString_FromStringOrNULL(cli_credentials_get_forced_sasl_mech(creds
));
602 static PyObject
*py_creds_set_forced_sasl_mech(PyObject
*self
, PyObject
*args
)
605 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
607 PyErr_Format(PyExc_TypeError
, "Credentials expected");
611 if (!PyArg_ParseTuple(args
, "s", &newval
)) {
615 cli_credentials_set_forced_sasl_mech(creds
, newval
);
619 static PyObject
*py_creds_set_conf(PyObject
*self
, PyObject
*args
)
621 PyObject
*py_lp_ctx
= Py_None
;
622 struct loadparm_context
*lp_ctx
;
624 struct cli_credentials
*creds
;
627 creds
= PyCredentials_AsCliCredentials(self
);
629 PyErr_Format(PyExc_TypeError
, "Credentials expected");
633 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
)) {
637 mem_ctx
= talloc_new(NULL
);
638 if (mem_ctx
== NULL
) {
643 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
644 if (lp_ctx
== NULL
) {
645 talloc_free(mem_ctx
);
649 ok
= cli_credentials_set_conf(creds
, lp_ctx
);
650 talloc_free(mem_ctx
);
658 static PyObject
*py_creds_guess(PyObject
*self
, PyObject
*args
)
660 PyObject
*py_lp_ctx
= Py_None
;
661 struct loadparm_context
*lp_ctx
;
663 struct cli_credentials
*creds
;
666 creds
= PyCredentials_AsCliCredentials(self
);
668 PyErr_Format(PyExc_TypeError
, "Credentials expected");
672 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
))
675 mem_ctx
= talloc_new(NULL
);
676 if (mem_ctx
== NULL
) {
681 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
682 if (lp_ctx
== NULL
) {
683 talloc_free(mem_ctx
);
687 ok
= cli_credentials_guess(creds
, lp_ctx
);
688 talloc_free(mem_ctx
);
696 static PyObject
*py_creds_set_machine_account(PyObject
*self
, PyObject
*args
)
698 PyObject
*py_lp_ctx
= Py_None
;
699 struct loadparm_context
*lp_ctx
;
701 struct cli_credentials
*creds
;
704 creds
= PyCredentials_AsCliCredentials(self
);
706 PyErr_Format(PyExc_TypeError
, "Credentials expected");
710 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
))
713 mem_ctx
= talloc_new(NULL
);
714 if (mem_ctx
== NULL
) {
719 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
720 if (lp_ctx
== NULL
) {
721 talloc_free(mem_ctx
);
725 status
= cli_credentials_set_machine_account(creds
, lp_ctx
);
726 talloc_free(mem_ctx
);
728 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
733 static PyObject
*PyCredentialCacheContainer_from_ccache_container(struct ccache_container
*ccc
)
735 return pytalloc_reference(&PyCredentialCacheContainer
, ccc
);
739 static PyObject
*py_creds_get_named_ccache(PyObject
*self
, PyObject
*args
)
741 PyObject
*py_lp_ctx
= Py_None
;
742 char *ccache_name
= NULL
;
743 struct loadparm_context
*lp_ctx
;
744 struct ccache_container
*ccc
;
745 struct tevent_context
*event_ctx
;
747 const char *error_string
;
748 struct cli_credentials
*creds
;
751 creds
= PyCredentials_AsCliCredentials(self
);
753 PyErr_Format(PyExc_TypeError
, "Credentials expected");
757 if (!PyArg_ParseTuple(args
, "|Os", &py_lp_ctx
, &ccache_name
))
760 mem_ctx
= talloc_new(NULL
);
761 if (mem_ctx
== NULL
) {
766 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
767 if (lp_ctx
== NULL
) {
768 talloc_free(mem_ctx
);
772 event_ctx
= samba_tevent_context_init(mem_ctx
);
774 ret
= cli_credentials_get_named_ccache(creds
, event_ctx
, lp_ctx
,
775 ccache_name
, &ccc
, &error_string
);
776 talloc_unlink(mem_ctx
, lp_ctx
);
778 talloc_steal(ccc
, event_ctx
);
779 talloc_free(mem_ctx
);
780 return PyCredentialCacheContainer_from_ccache_container(ccc
);
783 PyErr_SetString(PyExc_RuntimeError
, error_string
?error_string
:"NULL");
785 talloc_free(mem_ctx
);
789 static PyObject
*py_creds_set_named_ccache(PyObject
*self
, PyObject
*args
)
791 struct loadparm_context
*lp_ctx
= NULL
;
792 enum credentials_obtained obt
= CRED_SPECIFIED
;
793 const char *error_string
= NULL
;
794 TALLOC_CTX
*mem_ctx
= NULL
;
796 PyObject
*py_lp_ctx
= Py_None
;
799 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
801 PyErr_Format(PyExc_TypeError
, "Credentials expected");
805 if (!PyArg_ParseTuple(args
, "s|iO", &newval
, &_obt
, &py_lp_ctx
))
809 mem_ctx
= talloc_new(NULL
);
810 if (mem_ctx
== NULL
) {
815 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
816 if (lp_ctx
== NULL
) {
817 talloc_free(mem_ctx
);
821 ret
= cli_credentials_set_ccache(creds
,
827 PyErr_SetString(PyExc_RuntimeError
,
828 error_string
!= NULL
? error_string
: "NULL");
829 talloc_free(mem_ctx
);
833 talloc_free(mem_ctx
);
837 static PyObject
*py_creds_set_gensec_features(PyObject
*self
, PyObject
*args
)
839 unsigned int gensec_features
;
840 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
842 PyErr_Format(PyExc_TypeError
, "Credentials expected");
846 if (!PyArg_ParseTuple(args
, "I", &gensec_features
))
849 cli_credentials_set_gensec_features(creds
,
856 static PyObject
*py_creds_get_gensec_features(PyObject
*self
, PyObject
*args
)
858 unsigned int gensec_features
;
859 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
861 PyErr_Format(PyExc_TypeError
, "Credentials expected");
865 gensec_features
= cli_credentials_get_gensec_features(creds
);
866 return PyLong_FromLong(gensec_features
);
869 static PyObject
*py_creds_new_client_authenticator(PyObject
*self
,
872 struct netr_Authenticator auth
;
873 struct cli_credentials
*creds
= NULL
;
874 struct netlogon_creds_CredentialState
*nc
= NULL
;
875 PyObject
*ret
= NULL
;
878 creds
= PyCredentials_AsCliCredentials(self
);
880 PyErr_SetString(PyExc_RuntimeError
,
881 "Failed to get credentials from python");
885 nc
= creds
->netlogon_creds
;
887 PyErr_SetString(PyExc_ValueError
,
888 "No netlogon credentials cannot make "
889 "client authenticator");
893 status
= netlogon_creds_client_authenticator(nc
, &auth
);
894 if (!NT_STATUS_IS_OK(status
)) {
895 PyErr_SetString(PyExc_ValueError
,
896 "Failed to create client authenticator");
900 ret
= Py_BuildValue("{s"PYARG_BYTES_LEN
"si}",
902 (const char *) &auth
.cred
, sizeof(auth
.cred
),
903 "timestamp", auth
.timestamp
);
907 static PyObject
*py_creds_set_secure_channel_type(PyObject
*self
, PyObject
*args
)
909 unsigned int channel_type
;
910 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
912 PyErr_Format(PyExc_TypeError
, "Credentials expected");
916 if (!PyArg_ParseTuple(args
, "I", &channel_type
))
919 cli_credentials_set_secure_channel_type(
926 static PyObject
*py_creds_get_secure_channel_type(PyObject
*self
, PyObject
*args
)
928 enum netr_SchannelType channel_type
= SEC_CHAN_NULL
;
929 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
931 PyErr_Format(PyExc_TypeError
, "Credentials expected");
935 channel_type
= cli_credentials_get_secure_channel_type(creds
);
937 return PyLong_FromLong(channel_type
);
940 static PyObject
*py_creds_get_aes256_key(PyObject
*self
, PyObject
*args
)
942 struct loadparm_context
*lp_ctx
= NULL
;
943 TALLOC_CTX
*mem_ctx
= NULL
;
944 PyObject
*py_lp_ctx
= Py_None
;
945 const char *salt
= NULL
;
948 PyObject
*ret
= NULL
;
949 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
951 PyErr_Format(PyExc_TypeError
, "Credentials expected");
955 if (!PyArg_ParseTuple(args
, "s|O", &salt
, &py_lp_ctx
))
958 mem_ctx
= talloc_new(NULL
);
959 if (mem_ctx
== NULL
) {
964 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
965 if (lp_ctx
== NULL
) {
966 talloc_free(mem_ctx
);
970 code
= cli_credentials_get_aes256_key(creds
,
976 PyErr_SetString(PyExc_RuntimeError
,
977 "Failed to generate AES256 key");
978 talloc_free(mem_ctx
);
982 ret
= PyBytes_FromStringAndSize((const char *)aes_256
.data
,
984 talloc_free(mem_ctx
);
988 static PyObject
*py_creds_encrypt_netr_crypt_password(PyObject
*self
,
991 DATA_BLOB data
= data_blob_null
;
992 struct cli_credentials
*creds
= NULL
;
993 struct netr_CryptPassword
*pwd
= NULL
;
995 PyObject
*py_cp
= Py_None
;
997 creds
= PyCredentials_AsCliCredentials(self
);
999 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1003 if (!PyArg_ParseTuple(args
, "O", &py_cp
)) {
1007 pwd
= pytalloc_get_type(py_cp
, struct netr_CryptPassword
);
1009 /* pytalloc_get_type sets TypeError */
1012 data
.length
= sizeof(struct netr_CryptPassword
);
1013 data
.data
= (uint8_t *)pwd
;
1014 status
= netlogon_creds_session_encrypt(creds
->netlogon_creds
, data
);
1016 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
1021 static PyObject
*py_creds_encrypt_samr_password(PyObject
*self
,
1024 DATA_BLOB data
= data_blob_null
;
1025 struct cli_credentials
*creds
= NULL
;
1026 struct samr_Password
*pwd
= NULL
;
1028 PyObject
*py_cp
= Py_None
;
1030 creds
= PyCredentials_AsCliCredentials(self
);
1031 if (creds
== NULL
) {
1032 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1036 if (!PyArg_ParseTuple(args
, "O", &py_cp
)) {
1040 pwd
= pytalloc_get_type(py_cp
, struct samr_Password
);
1042 /* pytalloc_get_type sets TypeError */
1045 data
= data_blob_const(pwd
->hash
, sizeof(pwd
->hash
));
1046 status
= netlogon_creds_session_encrypt(creds
->netlogon_creds
, data
);
1048 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
1053 static PyObject
*py_creds_get_smb_signing(PyObject
*self
, PyObject
*unused
)
1055 enum smb_signing_setting signing_state
;
1056 struct cli_credentials
*creds
= NULL
;
1058 creds
= PyCredentials_AsCliCredentials(self
);
1059 if (creds
== NULL
) {
1060 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1064 signing_state
= cli_credentials_get_smb_signing(creds
);
1065 return PyLong_FromLong(signing_state
);
1068 static PyObject
*py_creds_set_smb_signing(PyObject
*self
, PyObject
*args
)
1070 enum smb_signing_setting signing_state
;
1071 struct cli_credentials
*creds
= NULL
;
1072 enum credentials_obtained obt
= CRED_SPECIFIED
;
1074 creds
= PyCredentials_AsCliCredentials(self
);
1075 if (creds
== NULL
) {
1076 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1079 if (!PyArg_ParseTuple(args
, "i|i", &signing_state
, &obt
)) {
1083 switch (signing_state
) {
1084 case SMB_SIGNING_DEFAULT
:
1085 case SMB_SIGNING_OFF
:
1086 case SMB_SIGNING_IF_REQUIRED
:
1087 case SMB_SIGNING_DESIRED
:
1088 case SMB_SIGNING_REQUIRED
:
1091 PyErr_Format(PyExc_TypeError
, "Invalid signing state value");
1095 cli_credentials_set_smb_signing(creds
, signing_state
, obt
);
1099 static PyObject
*py_creds_get_smb_ipc_signing(PyObject
*self
, PyObject
*unused
)
1101 enum smb_signing_setting signing_state
;
1102 struct cli_credentials
*creds
= NULL
;
1104 creds
= PyCredentials_AsCliCredentials(self
);
1105 if (creds
== NULL
) {
1106 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1110 signing_state
= cli_credentials_get_smb_ipc_signing(creds
);
1111 return PyLong_FromLong(signing_state
);
1114 static PyObject
*py_creds_set_smb_ipc_signing(PyObject
*self
, PyObject
*args
)
1116 enum smb_signing_setting signing_state
;
1117 struct cli_credentials
*creds
= NULL
;
1118 enum credentials_obtained obt
= CRED_SPECIFIED
;
1120 creds
= PyCredentials_AsCliCredentials(self
);
1121 if (creds
== NULL
) {
1122 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1125 if (!PyArg_ParseTuple(args
, "i|i", &signing_state
, &obt
)) {
1129 switch (signing_state
) {
1130 case SMB_SIGNING_DEFAULT
:
1131 case SMB_SIGNING_OFF
:
1132 case SMB_SIGNING_IF_REQUIRED
:
1133 case SMB_SIGNING_DESIRED
:
1134 case SMB_SIGNING_REQUIRED
:
1137 PyErr_Format(PyExc_TypeError
, "Invalid signing state value");
1141 cli_credentials_set_smb_ipc_signing(creds
, signing_state
, obt
);
1145 static PyObject
*py_creds_get_smb_encryption(PyObject
*self
, PyObject
*unused
)
1147 enum smb_encryption_setting encryption_state
;
1148 struct cli_credentials
*creds
= NULL
;
1150 creds
= PyCredentials_AsCliCredentials(self
);
1151 if (creds
== NULL
) {
1152 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1156 encryption_state
= cli_credentials_get_smb_encryption(creds
);
1157 return PyLong_FromLong(encryption_state
);
1160 static PyObject
*py_creds_set_smb_encryption(PyObject
*self
, PyObject
*args
)
1162 enum smb_encryption_setting encryption_state
;
1163 struct cli_credentials
*creds
= NULL
;
1164 enum credentials_obtained obt
= CRED_SPECIFIED
;
1166 creds
= PyCredentials_AsCliCredentials(self
);
1167 if (creds
== NULL
) {
1168 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1171 if (!PyArg_ParseTuple(args
, "i|i", &encryption_state
, &obt
)) {
1175 switch (encryption_state
) {
1176 case SMB_ENCRYPTION_DEFAULT
:
1177 case SMB_ENCRYPTION_OFF
:
1178 case SMB_ENCRYPTION_IF_REQUIRED
:
1179 case SMB_ENCRYPTION_DESIRED
:
1180 case SMB_ENCRYPTION_REQUIRED
:
1183 PyErr_Format(PyExc_TypeError
, "Invalid encryption state value");
1187 (void)cli_credentials_set_smb_encryption(creds
, encryption_state
, obt
);
1191 static PyMethodDef py_creds_methods
[] = {
1193 .ml_name
= "get_username",
1194 .ml_meth
= py_creds_get_username
,
1195 .ml_flags
= METH_NOARGS
,
1196 .ml_doc
= "S.get_username() -> username\nObtain username.",
1199 .ml_name
= "set_username",
1200 .ml_meth
= py_creds_set_username
,
1201 .ml_flags
= METH_VARARGS
,
1202 .ml_doc
= "S.set_username(name[, credentials.SPECIFIED]) -> None\n"
1206 .ml_name
= "get_principal",
1207 .ml_meth
= py_creds_get_principal
,
1208 .ml_flags
= METH_NOARGS
,
1209 .ml_doc
= "S.get_principal() -> user@realm\nObtain user principal.",
1212 .ml_name
= "set_principal",
1213 .ml_meth
= py_creds_set_principal
,
1214 .ml_flags
= METH_VARARGS
,
1215 .ml_doc
= "S.set_principal(name[, credentials.SPECIFIED]) -> None\n"
1216 "Change principal.",
1219 .ml_name
= "get_password",
1220 .ml_meth
= py_creds_get_password
,
1221 .ml_flags
= METH_NOARGS
,
1222 .ml_doc
= "S.get_password() -> password\n"
1226 .ml_name
= "get_ntlm_username_domain",
1227 .ml_meth
= py_creds_get_ntlm_username_domain
,
1228 .ml_flags
= METH_NOARGS
,
1229 .ml_doc
= "S.get_ntlm_username_domain() -> (domain, username)\n"
1230 "Obtain NTLM username and domain, split up either as (DOMAIN, user) or (\"\", \"user@realm\").",
1233 .ml_name
= "get_ntlm_response",
1234 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
1235 py_creds_get_ntlm_response
),
1236 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
1237 .ml_doc
= "S.get_ntlm_response"
1238 "(flags, challenge[, target_info]) -> "
1239 "(flags, lm_response, nt_response, lm_session_key, nt_session_key)\n"
1240 "Obtain LM or NTLM response.",
1243 .ml_name
= "set_password",
1244 .ml_meth
= py_creds_set_password
,
1245 .ml_flags
= METH_VARARGS
,
1246 .ml_doc
= "S.set_password(password[, credentials.SPECIFIED]) -> None\n"
1250 .ml_name
= "set_utf16_password",
1251 .ml_meth
= py_creds_set_utf16_password
,
1252 .ml_flags
= METH_VARARGS
,
1253 .ml_doc
= "S.set_utf16_password(password[, credentials.SPECIFIED]) -> None\n"
1257 .ml_name
= "get_old_password",
1258 .ml_meth
= py_creds_get_old_password
,
1259 .ml_flags
= METH_NOARGS
,
1260 .ml_doc
= "S.get_old_password() -> password\n"
1261 "Obtain old password.",
1264 .ml_name
= "set_old_password",
1265 .ml_meth
= py_creds_set_old_password
,
1266 .ml_flags
= METH_VARARGS
,
1267 .ml_doc
= "S.set_old_password(password[, credentials.SPECIFIED]) -> None\n"
1268 "Change old password.",
1271 .ml_name
= "set_old_utf16_password",
1272 .ml_meth
= py_creds_set_old_utf16_password
,
1273 .ml_flags
= METH_VARARGS
,
1274 .ml_doc
= "S.set_old_utf16_password(password[, credentials.SPECIFIED]) -> None\n"
1275 "Change old password.",
1278 .ml_name
= "get_domain",
1279 .ml_meth
= py_creds_get_domain
,
1280 .ml_flags
= METH_NOARGS
,
1281 .ml_doc
= "S.get_domain() -> domain\n"
1282 "Obtain domain name.",
1285 .ml_name
= "set_domain",
1286 .ml_meth
= py_creds_set_domain
,
1287 .ml_flags
= METH_VARARGS
,
1288 .ml_doc
= "S.set_domain(domain[, credentials.SPECIFIED]) -> None\n"
1289 "Change domain name.",
1292 .ml_name
= "get_realm",
1293 .ml_meth
= py_creds_get_realm
,
1294 .ml_flags
= METH_NOARGS
,
1295 .ml_doc
= "S.get_realm() -> realm\n"
1296 "Obtain realm name.",
1299 .ml_name
= "set_realm",
1300 .ml_meth
= py_creds_set_realm
,
1301 .ml_flags
= METH_VARARGS
,
1302 .ml_doc
= "S.set_realm(realm[, credentials.SPECIFIED]) -> None\n"
1303 "Change realm name.",
1306 .ml_name
= "get_bind_dn",
1307 .ml_meth
= py_creds_get_bind_dn
,
1308 .ml_flags
= METH_NOARGS
,
1309 .ml_doc
= "S.get_bind_dn() -> bind dn\n"
1313 .ml_name
= "set_bind_dn",
1314 .ml_meth
= py_creds_set_bind_dn
,
1315 .ml_flags
= METH_VARARGS
,
1316 .ml_doc
= "S.set_bind_dn(bind_dn) -> None\n"
1320 .ml_name
= "is_anonymous",
1321 .ml_meth
= py_creds_is_anonymous
,
1322 .ml_flags
= METH_NOARGS
,
1325 .ml_name
= "set_anonymous",
1326 .ml_meth
= py_creds_set_anonymous
,
1327 .ml_flags
= METH_NOARGS
,
1328 .ml_doc
= "S.set_anonymous() -> None\n"
1329 "Use anonymous credentials.",
1332 .ml_name
= "get_workstation",
1333 .ml_meth
= py_creds_get_workstation
,
1334 .ml_flags
= METH_NOARGS
,
1337 .ml_name
= "set_workstation",
1338 .ml_meth
= py_creds_set_workstation
,
1339 .ml_flags
= METH_VARARGS
,
1342 .ml_name
= "authentication_requested",
1343 .ml_meth
= py_creds_authentication_requested
,
1344 .ml_flags
= METH_NOARGS
,
1347 .ml_name
= "wrong_password",
1348 .ml_meth
= py_creds_wrong_password
,
1349 .ml_flags
= METH_NOARGS
,
1350 .ml_doc
= "S.wrong_password() -> bool\n"
1351 "Indicate the returned password was incorrect.",
1354 .ml_name
= "set_cmdline_callbacks",
1355 .ml_meth
= py_creds_set_cmdline_callbacks
,
1356 .ml_flags
= METH_NOARGS
,
1357 .ml_doc
= "S.set_cmdline_callbacks() -> bool\n"
1358 "Use command-line to obtain credentials not explicitly set.",
1361 .ml_name
= "parse_string",
1362 .ml_meth
= py_creds_parse_string
,
1363 .ml_flags
= METH_VARARGS
,
1364 .ml_doc
= "S.parse_string(text[, credentials.SPECIFIED]) -> None\n"
1365 "Parse credentials string.",
1368 .ml_name
= "parse_file",
1369 .ml_meth
= py_creds_parse_file
,
1370 .ml_flags
= METH_VARARGS
,
1371 .ml_doc
= "S.parse_file(filename[, credentials.SPECIFIED]) -> None\n"
1372 "Parse credentials file.",
1375 .ml_name
= "set_password_will_be_nt_hash",
1376 .ml_meth
= py_cli_credentials_set_password_will_be_nt_hash
,
1377 .ml_flags
= METH_VARARGS
,
1378 .ml_doc
= "S.set_password_will_be_nt_hash(bool) -> None\n"
1379 "Alters the behaviour of S.set_password() "
1380 "to expect the NTHASH as hexstring.",
1383 .ml_name
= "get_nt_hash",
1384 .ml_meth
= py_creds_get_nt_hash
,
1385 .ml_flags
= METH_NOARGS
,
1388 .ml_name
= "get_kerberos_state",
1389 .ml_meth
= py_creds_get_kerberos_state
,
1390 .ml_flags
= METH_NOARGS
,
1393 .ml_name
= "set_kerberos_state",
1394 .ml_meth
= py_creds_set_kerberos_state
,
1395 .ml_flags
= METH_VARARGS
,
1398 .ml_name
= "set_krb_forwardable",
1399 .ml_meth
= py_creds_set_krb_forwardable
,
1400 .ml_flags
= METH_VARARGS
,
1403 .ml_name
= "set_conf",
1404 .ml_meth
= py_creds_set_conf
,
1405 .ml_flags
= METH_VARARGS
,
1409 .ml_meth
= py_creds_guess
,
1410 .ml_flags
= METH_VARARGS
,
1413 .ml_name
= "set_machine_account",
1414 .ml_meth
= py_creds_set_machine_account
,
1415 .ml_flags
= METH_VARARGS
,
1418 .ml_name
= "get_named_ccache",
1419 .ml_meth
= py_creds_get_named_ccache
,
1420 .ml_flags
= METH_VARARGS
,
1423 .ml_name
= "set_named_ccache",
1424 .ml_meth
= py_creds_set_named_ccache
,
1425 .ml_flags
= METH_VARARGS
,
1426 .ml_doc
= "S.set_named_ccache(krb5_ccache_name, obtained, lp) -> None\n"
1427 "Set credentials to KRB5 Credentials Cache (by name).",
1430 .ml_name
= "set_gensec_features",
1431 .ml_meth
= py_creds_set_gensec_features
,
1432 .ml_flags
= METH_VARARGS
,
1435 .ml_name
= "get_gensec_features",
1436 .ml_meth
= py_creds_get_gensec_features
,
1437 .ml_flags
= METH_NOARGS
,
1440 .ml_name
= "get_forced_sasl_mech",
1441 .ml_meth
= py_creds_get_forced_sasl_mech
,
1442 .ml_flags
= METH_NOARGS
,
1443 .ml_doc
= "S.get_forced_sasl_mech() -> SASL mechanism\nObtain forced SASL mechanism.",
1446 .ml_name
= "set_forced_sasl_mech",
1447 .ml_meth
= py_creds_set_forced_sasl_mech
,
1448 .ml_flags
= METH_VARARGS
,
1449 .ml_doc
= "S.set_forced_sasl_mech(name) -> None\n"
1450 "Set forced SASL mechanism.",
1453 .ml_name
= "new_client_authenticator",
1454 .ml_meth
= py_creds_new_client_authenticator
,
1455 .ml_flags
= METH_NOARGS
,
1456 .ml_doc
= "S.new_client_authenticator() -> Authenticator\n"
1457 "Get a new client NETLOGON_AUTHENTICATOR"},
1459 .ml_name
= "set_secure_channel_type",
1460 .ml_meth
= py_creds_set_secure_channel_type
,
1461 .ml_flags
= METH_VARARGS
,
1464 .ml_name
= "get_secure_channel_type",
1465 .ml_meth
= py_creds_get_secure_channel_type
,
1466 .ml_flags
= METH_VARARGS
,
1469 .ml_name
= "get_aes256_key",
1470 .ml_meth
= py_creds_get_aes256_key
,
1471 .ml_flags
= METH_VARARGS
,
1472 .ml_doc
= "S.get_aes256_key(salt[, lp]) -> bytes\n"
1473 "Generate an AES256 key using the current password and\n"
1474 "the specified salt",
1477 .ml_name
= "encrypt_netr_crypt_password",
1478 .ml_meth
= py_creds_encrypt_netr_crypt_password
,
1479 .ml_flags
= METH_VARARGS
,
1480 .ml_doc
= "S.encrypt_netr_crypt_password(password) -> None\n"
1481 "Encrypt the supplied password using the session key and\n"
1482 "the negotiated encryption algorithm in place\n"
1483 "i.e. it overwrites the original data"},
1485 .ml_name
= "encrypt_samr_password",
1486 .ml_meth
= py_creds_encrypt_samr_password
,
1487 .ml_flags
= METH_VARARGS
,
1488 .ml_doc
= "S.encrypt_samr_password(password) -> None\n"
1489 "Encrypt the supplied password using the session key and\n"
1490 "the negotiated encryption algorithm in place\n"
1491 "i.e. it overwrites the original data"
1494 .ml_name
= "get_smb_signing",
1495 .ml_meth
= py_creds_get_smb_signing
,
1496 .ml_flags
= METH_NOARGS
,
1499 .ml_name
= "set_smb_signing",
1500 .ml_meth
= py_creds_set_smb_signing
,
1501 .ml_flags
= METH_VARARGS
,
1504 .ml_name
= "get_smb_ipc_signing",
1505 .ml_meth
= py_creds_get_smb_ipc_signing
,
1506 .ml_flags
= METH_NOARGS
,
1509 .ml_name
= "set_smb_ipc_signing",
1510 .ml_meth
= py_creds_set_smb_ipc_signing
,
1511 .ml_flags
= METH_VARARGS
,
1514 .ml_name
= "get_smb_encryption",
1515 .ml_meth
= py_creds_get_smb_encryption
,
1516 .ml_flags
= METH_NOARGS
,
1519 .ml_name
= "set_smb_encryption",
1520 .ml_meth
= py_creds_set_smb_encryption
,
1521 .ml_flags
= METH_VARARGS
,
1526 static struct PyModuleDef moduledef
= {
1527 PyModuleDef_HEAD_INIT
,
1528 .m_name
= "credentials",
1529 .m_doc
= "Credentials management.",
1531 .m_methods
= py_creds_methods
,
1534 PyTypeObject PyCredentials
= {
1535 .tp_name
= "credentials.Credentials",
1536 .tp_new
= py_creds_new
,
1537 .tp_flags
= Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
1538 .tp_methods
= py_creds_methods
,
1541 static PyObject
*py_ccache_name(PyObject
*self
, PyObject
*unused
)
1543 struct ccache_container
*ccc
= NULL
;
1545 PyObject
*py_name
= NULL
;
1548 ccc
= pytalloc_get_type(self
, struct ccache_container
);
1550 ret
= krb5_cc_get_full_name(ccc
->smb_krb5_context
->krb5_context
,
1551 ccc
->ccache
, &name
);
1553 py_name
= PyString_FromStringOrNULL(name
);
1556 PyErr_SetString(PyExc_RuntimeError
,
1557 "Failed to get ccache name");
1563 static PyMethodDef py_ccache_container_methods
[] = {
1564 { "get_name", py_ccache_name
, METH_NOARGS
,
1565 "S.get_name() -> name\nObtain KRB5 credentials cache name." },
1569 PyTypeObject PyCredentialCacheContainer
= {
1570 .tp_name
= "credentials.CredentialCacheContainer",
1571 .tp_flags
= Py_TPFLAGS_DEFAULT
,
1572 .tp_methods
= py_ccache_container_methods
,
1575 MODULE_INIT_FUNC(credentials
)
1578 if (pytalloc_BaseObject_PyType_Ready(&PyCredentials
) < 0)
1581 if (pytalloc_BaseObject_PyType_Ready(&PyCredentialCacheContainer
) < 0)
1584 m
= PyModule_Create(&moduledef
);
1588 PyModule_AddObject(m
, "UNINITIALISED", PyLong_FromLong(CRED_UNINITIALISED
));
1589 PyModule_AddObject(m
, "SMB_CONF", PyLong_FromLong(CRED_SMB_CONF
));
1590 PyModule_AddObject(m
, "CALLBACK", PyLong_FromLong(CRED_CALLBACK
));
1591 PyModule_AddObject(m
, "GUESS_ENV", PyLong_FromLong(CRED_GUESS_ENV
));
1592 PyModule_AddObject(m
, "GUESS_FILE", PyLong_FromLong(CRED_GUESS_FILE
));
1593 PyModule_AddObject(m
, "CALLBACK_RESULT", PyLong_FromLong(CRED_CALLBACK_RESULT
));
1594 PyModule_AddObject(m
, "SPECIFIED", PyLong_FromLong(CRED_SPECIFIED
));
1596 PyModule_AddObject(m
, "AUTO_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_DESIRED
));
1597 PyModule_AddObject(m
, "DONT_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_DISABLED
));
1598 PyModule_AddObject(m
, "MUST_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_REQUIRED
));
1600 PyModule_AddObject(m
, "AUTO_KRB_FORWARDABLE", PyLong_FromLong(CRED_AUTO_KRB_FORWARDABLE
));
1601 PyModule_AddObject(m
, "NO_KRB_FORWARDABLE", PyLong_FromLong(CRED_NO_KRB_FORWARDABLE
));
1602 PyModule_AddObject(m
, "FORCE_KRB_FORWARDABLE", PyLong_FromLong(CRED_FORCE_KRB_FORWARDABLE
));
1603 PyModule_AddObject(m
, "CLI_CRED_NTLM2", PyLong_FromLong(CLI_CRED_NTLM2
));
1604 PyModule_AddObject(m
, "CLI_CRED_NTLMv2_AUTH", PyLong_FromLong(CLI_CRED_NTLMv2_AUTH
));
1605 PyModule_AddObject(m
, "CLI_CRED_LANMAN_AUTH", PyLong_FromLong(CLI_CRED_LANMAN_AUTH
));
1606 PyModule_AddObject(m
, "CLI_CRED_NTLM_AUTH", PyLong_FromLong(CLI_CRED_NTLM_AUTH
));
1607 PyModule_AddObject(m
, "CLI_CRED_CLEAR_AUTH", PyLong_FromLong(CLI_CRED_CLEAR_AUTH
));
1609 PyModule_AddObject(m
, "SMB_SIGNING_DEFAULT", PyLong_FromLong(SMB_SIGNING_DEFAULT
));
1610 PyModule_AddObject(m
, "SMB_SIGNING_OFF", PyLong_FromLong(SMB_SIGNING_OFF
));
1611 PyModule_AddObject(m
, "SMB_SIGNING_IF_REQUIRED", PyLong_FromLong(SMB_SIGNING_IF_REQUIRED
));
1612 PyModule_AddObject(m
, "SMB_SIGNING_DESIRED", PyLong_FromLong(SMB_SIGNING_DESIRED
));
1613 PyModule_AddObject(m
, "SMB_SIGNING_REQUIRED", PyLong_FromLong(SMB_SIGNING_REQUIRED
));
1615 PyModule_AddObject(m
, "SMB_ENCRYPTION_DEFAULT", PyLong_FromLong(SMB_ENCRYPTION_DEFAULT
));
1616 PyModule_AddObject(m
, "SMB_ENCRYPTION_OFF", PyLong_FromLong(SMB_ENCRYPTION_OFF
));
1617 PyModule_AddObject(m
, "SMB_ENCRYPTION_IF_REQUIRED", PyLong_FromLong(SMB_ENCRYPTION_IF_REQUIRED
));
1618 PyModule_AddObject(m
, "SMB_ENCRYPTION_DESIRED", PyLong_FromLong(SMB_ENCRYPTION_DESIRED
));
1619 PyModule_AddObject(m
, "SMB_ENCRYPTION_REQUIRED", PyLong_FromLong(SMB_ENCRYPTION_REQUIRED
));
1621 Py_INCREF(&PyCredentials
);
1622 PyModule_AddObject(m
, "Credentials", (PyObject
*)&PyCredentials
);
1623 Py_INCREF(&PyCredentialCacheContainer
);
1624 PyModule_AddObject(m
, "CredentialCacheContainer", (PyObject
*)&PyCredentialCacheContainer
);