pydsdb: Raise a more useful exception when dsdb_wellknown_dn fails.
authorAndrew Bartlett <abartlet@samba.org>
Mon, 23 Sep 2013 02:26:10 +0000 (19:26 -0700)
committerMichael Adam <obnox@samba.org>
Tue, 24 Sep 2013 05:44:29 +0000 (07:44 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source4/dsdb/pydsdb.c

index 793c49522b01c0526f217a0516f064d4f543295e..ee02483acd4387806a847bb1363a8b4f2b64162b 100644 (file)
@@ -981,6 +981,11 @@ static PyObject *py_dsdb_get_wellknown_dn(PyObject *self, PyObject *args)
        PyErr_LDB_DN_OR_RAISE(py_nc_dn, nc_dn);
 
        ret = dsdb_wellknown_dn(ldb, ldb, nc_dn, wkguid, &wk_dn);
+       if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+               PyErr_Format(PyExc_KeyError, "Failed to find well known DN for GUID %s", wkguid);
+               return NULL;
+       }
+
        PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
 
        py_wk_dn = pyldb_Dn_FromDn(wk_dn);