s4:pydsdb: add not-implemented raising functions to when appropriate
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 21 Feb 2024 10:13:51 +0000 (23:13 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 29 Feb 2024 04:01:40 +0000 (04:01 +0000)
It will be less confusing, I hope.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/pydsdb.c

index aac311a84ff98872af48087293ce281d61bebf5f..9dfccf2cbc1d4211786b254ea4dde6d72d6de4b5 100644 (file)
@@ -1168,6 +1168,18 @@ static PyObject *py_dsdb_allocate_rid(PyObject *self, PyObject *args)
 }
 
 #ifdef AD_DC_BUILD_IS_ENABLED
+/*
+ * These functions will not work correctly on non-AD_DC builds.
+ *
+ * The only real principal in deciding whether to put something within
+ * these guards is whether it will compile and work when
+ * bld.AD_DC_BUILD_IS_ENABLED() says no.
+ *
+ * Most of DSDB is built and samba-tool will work fine with remote
+ * servers (using -H ldap://), but some DNS and periodic service
+ * functions are not built.
+ */
+
 static PyObject *py_dns_delete_tombstones(PyObject *self, PyObject *args)
 {
        PyObject *py_ldb;
@@ -1333,7 +1345,18 @@ static PyObject *py_dsdb_garbage_collect_tombstones(PyObject *self, PyObject *ar
        return Py_BuildValue("(II)", num_objects_removed,
                            num_links_removed);
 }
-#endif
+
+#else
+
+static PyObject *py_dsdb_not_implemented(PyObject *self, PyObject *args)
+{
+       PyErr_SetString(PyExc_NotImplementedError,
+                       "Library built without AD DC support");
+       return NULL;
+}
+
+#endif /* AD_DC_BUILD_IS_ENABLED */
+
 
 static PyObject *py_dsdb_load_udv_v2(PyObject *self, PyObject *args)
 {
@@ -1481,7 +1504,7 @@ static PyMethodDef py_dsdb_methods[] = {
        { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
                METH_VARARGS, "Get the server site name as a string"},
        { "_dsdb_convert_schema_to_openldap",
-               (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS, 
+               (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
                "dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
                "Create an OpenLDAP schema from a schema." },
        { "_samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid,
@@ -1550,6 +1573,13 @@ static PyMethodDef py_dsdb_methods[] = {
                METH_VARARGS, NULL},
        { "_dns_delete_tombstones", (PyCFunction)py_dns_delete_tombstones,
                METH_VARARGS, NULL},
+#else
+       { "_dsdb_garbage_collect_tombstones", (PyCFunction)py_dsdb_not_implemented,
+               METH_VARARGS, NULL},
+       { "_scavenge_dns_records", (PyCFunction)py_dsdb_not_implemented,
+               METH_VARARGS, NULL},
+       { "_dns_delete_tombstones", (PyCFunction)py_dsdb_not_implemented,
+               METH_VARARGS, NULL},
 #endif
        { "_dsdb_create_own_rid_set", (PyCFunction)py_dsdb_create_own_rid_set, METH_VARARGS,
                "_dsdb_create_own_rid_set(samdb)"