diff options
author | Björn Baumbach <bb@sernet.de> | 2018-09-04 16:30:53 +0200 |
---|---|---|
committer | Björn Baumbach <bb@sernet.de> | 2018-10-11 10:28:18 +0200 |
commit | 01ff09adccc88367e807bbf5d5e8cd2eae6a38b0 (patch) | |
tree | 88d5dd68e1a586a1621386a21f7ee4426335a698 /source3/passdb | |
parent | 38fe315bcf7c20ae00f2b1ad5e497a8d1046850d (diff) | |
download | samba-01ff09adccc88367e807bbf5d5e8cd2eae6a38b0.tar.gz |
s3/py_passdb: add get_domain_sid() to get domain sid from secrets database
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/py_passdb.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c index 31e3907c8bc..1bcf3f667ec 100644 --- a/source3/passdb/py_passdb.c +++ b/source3/passdb/py_passdb.c @@ -3662,6 +3662,31 @@ static PyObject *py_reload_static_pdb(PyObject *self, PyObject *args) Py_RETURN_NONE; } +static PyObject *py_get_domain_sid(PyObject *self, PyObject *unused) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct dom_sid domain_sid, *domain_sid_copy; + PyObject *py_dom_sid = Py_None; + bool ret = false; + + ret = secrets_fetch_domain_sid(lp_workgroup(), &domain_sid); + if (!ret) { + talloc_free(frame); + return PyErr_NoMemory(); + } + + domain_sid_copy = dom_sid_dup(frame, &domain_sid); + if (domain_sid_copy == NULL) { + talloc_free(frame); + return PyErr_NoMemory(); + } + + py_dom_sid = pytalloc_steal(dom_sid_Type, domain_sid_copy); + + talloc_free(frame); + return py_dom_sid; +} + static PyObject *py_get_global_sam_sid(PyObject *self, PyObject *unused) { TALLOC_CTX *frame = talloc_stackframe(); @@ -3697,6 +3722,9 @@ static PyMethodDef py_passdb_methods[] = { { "get_global_sam_sid", py_get_global_sam_sid, METH_NOARGS, "get_global_sam_sid() -> dom_sid\n\n \ Return domain SID." }, + { "get_domain_sid", py_get_domain_sid, METH_NOARGS, + "get_domain_sid() -> dom_sid\n\n \ + Return domain SID from secrets database." }, { "reload_static_pdb", py_reload_static_pdb, METH_NOARGS, "reload_static_pdb() -> None\n\n \ Re-initalise the static pdb used internally. Needed if 'passdb backend' is changed." }, |