]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:dsdb/common: add dsdb_module_werror() helper function
authorStefan Metzmacher <metze@samba.org>
Tue, 12 Jan 2016 14:51:01 +0000 (15:51 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 1 Feb 2016 08:53:10 +0000 (09:53 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/dsdb/common/util.c
source4/dsdb/common/util.h

index b0c89b7f792bf8c0c475e331ab4472f67aebd5b8..dd25987ffc06960cce50171e292484ccb50885eb 100644 (file)
@@ -4867,6 +4867,17 @@ bool is_attr_in_list(const char * const * attrs, const char *attr)
        return false;
 }
 
+int dsdb_werror_at(struct ldb_context *ldb, int ldb_ecode, WERROR werr,
+                  const char *location, const char *func,
+                  const char *reason)
+{
+       if (reason == NULL) {
+               reason = win_errstr(werr);
+       }
+       ldb_asprintf_errstring(ldb, "%08X: %s at %s:%s",
+                              W_ERROR_V(werr), reason, location, func);
+       return ldb_ecode;
+}
 
 /*
   map an ldb error code to an approximate NTSTATUS code
index dcf3fc44b13c12ee8fc26653dd3f0dbd0e0c5145..10850736e7dc2a30d3e2d5b82970544a630e0f64 100644 (file)
@@ -69,4 +69,14 @@ struct GUID;
 char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
 NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid);
 
+struct ldb_context;
+
+int dsdb_werror_at(struct ldb_context *ldb, int ldb_ecode, WERROR werr,
+                  const char *location, const char *func,
+                  const char *reason);
+
+#define dsdb_module_werror(module, ldb_ecode, werr, reason) \
+       dsdb_werror_at(ldb_module_get_ctx(module), ldb_ecode, werr, \
+                      __location__, __func__, reason)
+
 #endif /* __DSDB_COMMON_UTIL_H__ */