pydsdb: provide a am_pdc hook like am_rodc to python scripts
authorAndrew Bartlett <abartlet@samba.org>
Tue, 6 Dec 2011 22:56:31 +0000 (09:56 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 7 Dec 2011 02:09:08 +0000 (03:09 +0100)
source4/dsdb/pydsdb.c
source4/scripting/python/samba/samdb.py

index 3c7c8bfaa12c439a153453d1d4a03bed32812ac9..738ea6d64158a4bf2cad8138d1410ae76008918c 100644 (file)
@@ -945,6 +945,25 @@ static PyObject *py_dsdb_am_rodc(PyObject *self, PyObject *args)
        return PyBool_FromLong(am_rodc);
 }
 
+/*
+  call into samdb_is_pdc()
+ */
+static PyObject *py_dsdb_am_pdc(PyObject *self, PyObject *args)
+{
+       PyObject *py_ldb;
+       struct ldb_context *ldb;
+       int ret;
+       bool am_pdc;
+
+       if (!PyArg_ParseTuple(args, "O", &py_ldb))
+               return NULL;
+
+       PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+       am_pdc = samdb_is_pdc(ldb);
+       return PyBool_FromLong(am_pdc);
+}
+
 
 static PyMethodDef py_dsdb_methods[] = {
        { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
@@ -997,6 +1016,9 @@ static PyMethodDef py_dsdb_methods[] = {
        { "_am_rodc",
                (PyCFunction)py_dsdb_am_rodc, METH_VARARGS,
                NULL },
+       { "_am_pdc",
+               (PyCFunction)py_dsdb_am_pdc, METH_VARARGS,
+               NULL },
        { "_dsdb_set_schema_from_ldif", (PyCFunction)py_dsdb_set_schema_from_ldif, METH_VARARGS,
                NULL },
        { "_dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
index 4bd1acde4c36bb721bbd6c6baaf16438c6e155f8..98c36bf38b22972bcf9fce0052d5c16fbd3969c5 100644 (file)
@@ -76,6 +76,10 @@ class SamDB(samba.Ldb):
         '''return True if we are an RODC'''
         return dsdb._am_rodc(self)
 
+    def am_pdc(self):
+        '''return True if we are an PDC emulator'''
+        return dsdb._am_pdc(self)
+
     def domain_dn(self):
         '''return the domain DN'''
         return str(self.get_default_basedn())