The branch, master has been updated
       via  160c197b8456ef5cd70c8297d8a7efc3dca178ec (commit)
      from  6c55518d471950d8ebaf0df47634116802d6f735 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 160c197b8456ef5cd70c8297d8a7efc3dca178ec
Author: Andrew Bartlett <[email protected]>
Date:   Thu Aug 27 19:38:04 2009 +1000

    s4:python Add helper to get at the domain SID

-----------------------------------------------------------------------

Summary of changes:
 source4/scripting/python/pyglue.c          |   27 +++++++++++++++++++++++++++
 source4/scripting/python/samba/__init__.py |    6 ++++++
 2 files changed, 33 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/scripting/python/pyglue.c 
b/source4/scripting/python/pyglue.c
index 55ba5c3..79ee0ec 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -194,6 +194,30 @@ static PyObject *py_samdb_set_domain_sid(PyLdbObject 
*self, PyObject *args)
        Py_RETURN_NONE;
 }
 
+static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args)
+{ 
+       PyObject *py_ldb;
+       struct ldb_context *ldb;
+       const struct dom_sid *sid;
+       PyObject *ret;
+       char *retstr;
+
+       if (!PyArg_ParseTuple(args, "O", &py_ldb))
+               return NULL;
+       
+       PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+       sid = samdb_domain_sid(ldb);
+       if (!sid) {
+               PyErr_SetString(PyExc_RuntimeError, "samdb_domain_sid failed");
+               return NULL;
+       } 
+       retstr = dom_sid_string(NULL, sid);
+       ret = PyString_FromString(retstr);
+       talloc_free(retstr);
+       return ret;
+}
+
 static PyObject *py_ldb_register_samba_handlers(PyObject *self, PyObject *args)
 {
        PyObject *py_ldb;
@@ -434,6 +458,9 @@ static PyMethodDef py_misc_methods[] = {
        { "samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid, 
METH_VARARGS,
                "samdb_set_domain_sid(samdb, sid)\n"
                "Set SID of domain to use." },
+       { "samdb_get_domain_sid", (PyCFunction)py_samdb_get_domain_sid, 
METH_VARARGS,
+               "samdb_get_domain_sid(samdb)\n"
+               "Get SID of domain in use." },
        { "ldb_register_samba_handlers", 
(PyCFunction)py_ldb_register_samba_handlers, METH_VARARGS,
                "ldb_register_samba_handlers(ldb)\n"
                "Register Samba-specific LDB modules and schemas." },
diff --git a/source4/scripting/python/samba/__init__.py 
b/source4/scripting/python/samba/__init__.py
index 4df3d6f..720a015 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -233,6 +233,12 @@ class Ldb(ldb.Ldb):
         """
         glue.samdb_set_domain_sid(self, sid)
 
+    def domain_sid(self):
+        """Read the domain SID used by this LDB.
+
+        """
+        glue.samdb_get_domain_sid(self)
+
     def set_schema_from_ldif(self, pf, df):
         glue.dsdb_set_schema_from_ldif(self, pf, df)
 


-- 
Samba Shared Repository

Reply via email to