static PyObject *py_creds_set_machine_account(PyObject *self, PyObject *args) { PyObject *py_lp_ctx = Py_None; struct loadparm_context *lp_ctx; NTSTATUS status; struct cli_credentials *creds; TALLOC_CTX *mem_ctx; creds = PyCredentials_AsCliCredentials(self); if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx)) return NULL; mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { PyErr_NoMemory(); return NULL; } lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx); if (lp_ctx == NULL) { talloc_free(mem_ctx); return NULL; } status = cli_credentials_set_machine_account(creds, lp_ctx); talloc_free(mem_ctx); PyErr_NTSTATUS_IS_ERR_RAISE(status); Py_RETURN_NONE; }
static PyObject *py_creds_guess(PyObject *self, PyObject *args) { PyObject *py_lp_ctx = Py_None; struct loadparm_context *lp_ctx; TALLOC_CTX *mem_ctx; struct cli_credentials *creds; creds = PyCredentials_AsCliCredentials(self); if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx)) return NULL; mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { PyErr_NoMemory(); return NULL; } lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx); if (lp_ctx == NULL) { talloc_free(mem_ctx); return NULL; } cli_credentials_guess(creds, lp_ctx); talloc_free(mem_ctx); Py_RETURN_NONE; }
static PyObject *py_creds_get_gensec_features(PyObject *self, PyObject *args) { unsigned int gensec_features; gensec_features = cli_credentials_get_gensec_features(PyCredentials_AsCliCredentials(self)); return PyInt_FromLong(gensec_features); }
static PyObject *py_creds_set_utf16_password(PyObject *self, PyObject *args) { enum credentials_obtained obt = CRED_SPECIFIED; int _obt = obt; PyObject *newval = NULL; DATA_BLOB blob = data_blob_null; Py_ssize_t size = 0; int result; bool ok; if (!PyArg_ParseTuple(args, "O|i", &newval, &_obt)) { return NULL; } obt = _obt; result = PyBytes_AsStringAndSize(newval, (char **)&blob.data, &size); if (result != 0) { PyErr_SetString(PyExc_RuntimeError, "Failed to convert passed value to Bytes"); return NULL; } blob.length = size; ok = cli_credentials_set_utf16_password(PyCredentials_AsCliCredentials(self), &blob, obt); return PyBool_FromLong(ok); }
static PyObject *py_creds_get_principal(PyObject *self, PyObject *unused) { TALLOC_CTX *frame = talloc_stackframe(); PyObject *ret = PyString_FromStringOrNULL(cli_credentials_get_principal(PyCredentials_AsCliCredentials(self), frame)); TALLOC_FREE(frame); return ret; }
static PyObject *py_creds_set_bind_dn(PyObject *self, PyObject *args) { char *newval; if (!PyArg_ParseTuple(args, "s", &newval)) return NULL; return PyBool_FromLong(cli_credentials_set_bind_dn(PyCredentials_AsCliCredentials(self), newval)); }
static PyObject *py_creds_set_krb_forwardable(PyObject *self, PyObject *args) { int state; if (!PyArg_ParseTuple(args, "i", &state)) return NULL; cli_credentials_set_krb_forwardable(PyCredentials_AsCliCredentials(self), state); Py_RETURN_NONE; }
static PyObject *py_creds_get_nt_hash(PyObject *self, PyObject *unused) { PyObject *ret; struct cli_credentials *creds = PyCredentials_AsCliCredentials(self); struct samr_Password *ntpw = cli_credentials_get_nt_hash(creds, creds); ret = PyString_FromStringAndSize(discard_const_p(char, ntpw->hash), 16); TALLOC_FREE(ntpw); return ret; }
static PyObject *py_creds_set_gensec_features(PyObject *self, PyObject *args) { unsigned int gensec_features; if (!PyArg_ParseTuple(args, "I", &gensec_features)) return NULL; cli_credentials_set_gensec_features(PyCredentials_AsCliCredentials(self), gensec_features); Py_RETURN_NONE; }
static PyObject *py_creds_set_principal(PyObject *self, PyObject *args) { char *newval; enum credentials_obtained obt = CRED_SPECIFIED; int _obt = obt; if (!PyArg_ParseTuple(args, "s|i", &newval, &_obt)) { return NULL; } obt = _obt; return PyBool_FromLong(cli_credentials_set_principal(PyCredentials_AsCliCredentials(self), newval, obt)); }
static PyObject *py_creds_parse_string(PyObject *self, PyObject *args) { char *newval; enum credentials_obtained obt = CRED_SPECIFIED; int _obt = obt; if (!PyArg_ParseTuple(args, "s|i", &newval, &_obt)) { return NULL; } obt = _obt; cli_credentials_parse_string(PyCredentials_AsCliCredentials(self), newval, obt); Py_RETURN_NONE; }
static PyObject *py_creds_get_ntlm_username_domain(PyObject *self, PyObject *unused) { TALLOC_CTX *frame = talloc_stackframe(); const char *user = NULL; const char *domain = NULL; PyObject *ret = NULL; cli_credentials_get_ntlm_username_domain(PyCredentials_AsCliCredentials(self), frame, &user, &domain); ret = Py_BuildValue("(OO)", PyString_FromStringOrNULL(user), PyString_FromStringOrNULL(domain)); TALLOC_FREE(frame); return ret; }
static PyObject *py_creds_set_forced_sasl_mech(PyObject *self, PyObject *args) { char *newval; enum credentials_obtained obt = CRED_SPECIFIED; int _obt = obt; if (!PyArg_ParseTuple(args, "s", &newval)) { return NULL; } obt = _obt; cli_credentials_set_forced_sasl_mech(PyCredentials_AsCliCredentials(self), newval); Py_RETURN_NONE; }
static PyObject *py_creds_get_named_ccache(PyObject *self, PyObject *args) { PyObject *py_lp_ctx = Py_None; char *ccache_name; struct loadparm_context *lp_ctx; struct ccache_container *ccc; struct tevent_context *event_ctx; int ret; const char *error_string; struct cli_credentials *creds; TALLOC_CTX *mem_ctx; creds = PyCredentials_AsCliCredentials(self); if (!PyArg_ParseTuple(args, "|Os", &py_lp_ctx, &ccache_name)) return NULL; mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { PyErr_NoMemory(); return NULL; } lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx); if (lp_ctx == NULL) { talloc_free(mem_ctx); return NULL; } event_ctx = samba_tevent_context_init(mem_ctx); ret = cli_credentials_get_named_ccache(creds, event_ctx, lp_ctx, ccache_name, &ccc, &error_string); talloc_unlink(mem_ctx, lp_ctx); if (ret == 0) { talloc_steal(ccc, event_ctx); talloc_free(mem_ctx); return PyCredentialCacheContainer_from_ccache_container(ccc); } PyErr_SetString(PyExc_RuntimeError, error_string?error_string:"NULL"); talloc_free(mem_ctx); return NULL; }
static PyObject *py_creds_set_old_utf16_password(PyObject *self, PyObject *args) { PyObject *oldval = NULL; DATA_BLOB blob = data_blob_null; Py_ssize_t size = 0; int result; bool ok; if (!PyArg_ParseTuple(args, "O", &oldval)) { return NULL; } result = PyBytes_AsStringAndSize(oldval, (char **)&blob.data, &size); if (result != 0) { PyErr_SetString(PyExc_RuntimeError, "Failed to convert passed value to Bytes"); return NULL; } blob.length = size; ok = cli_credentials_set_old_utf16_password(PyCredentials_AsCliCredentials(self), &blob); return PyBool_FromLong(ok); }
static PyObject *py_creds_get_kerberos_state(PyObject *self, PyObject *unused) { int state = cli_credentials_get_kerberos_state(PyCredentials_AsCliCredentials(self)); return PyInt_FromLong(state); }
static PyObject *py_creds_get_domain(pytalloc_Object *self) { return PyString_FromStringOrNULL(cli_credentials_get_domain(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_is_anonymous(PyObject *self, PyObject *unused) { return PyBool_FromLong(cli_credentials_is_anonymous(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_set_anonymous(PyObject *self, PyObject *unused) { cli_credentials_set_anonymous(PyCredentials_AsCliCredentials(self)); Py_RETURN_NONE; }
static PyObject *py_creds_authentication_requested(PyObject *self, PyObject *unused) { return PyBool_FromLong(cli_credentials_authentication_requested(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_get_forced_sasl_mech(PyObject *self, PyObject *unused) { return PyString_FromStringOrNULL(cli_credentials_get_forced_sasl_mech(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_wrong_password(PyObject *self, PyObject *unused) { return PyBool_FromLong(cli_credentials_wrong_password(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_get_nt_hash(pytalloc_Object *self) { const struct samr_Password *ntpw = cli_credentials_get_nt_hash(PyCredentials_AsCliCredentials(self), self->ptr); return PyString_FromStringAndSize(discard_const_p(char, ntpw->hash), 16); }
static PyObject *py_creds_get_password(PyObject *self, PyObject *unused) { return PyString_FromStringOrNULL(cli_credentials_get_password(PyCredentials_AsCliCredentials(self))); }
static PyObject *py_creds_set_cmdline_callbacks(PyObject *self, PyObject *unused) { return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(PyCredentials_AsCliCredentials(self))); }
static int py_auth_session_set_credentials(PyObject *self, PyObject *value, void *closure) { struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info); session->credentials = talloc_reference(session, PyCredentials_AsCliCredentials(value)); return 0; }
static PyObject *py_creds_set_anonymous(pytalloc_Object *self) { cli_credentials_set_anonymous(PyCredentials_AsCliCredentials(self)); Py_RETURN_NONE; }