We can't use PyErr_LDB_MESSAGE_OR_RAISE() here, because the return type
is int, not PyObject*.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
{
struct ldb_message_element *el = NULL;
const char *name = NULL;
- struct ldb_message *msg = pyldb_Message_AsMessage(self);
+ struct ldb_message *msg = pyldb_Message_as_message(self);
+ struct ldb_dn *dn = msg->dn;
+
+ if (dn != NULL && (self->pyldb->ldb_ctx != ldb_dn_get_ldb_context(dn))) {
+ return -1;
+ }
+
name = PyUnicode_AsUTF8(py_name);
if (name == NULL) {
return -1;