diff options
author | Stefan Metzmacher <metze@samba.org> | 2016-01-12 15:51:01 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2016-02-01 09:53:10 +0100 |
commit | cff0978495da54c019148709a07ccf5f947cf5ec (patch) | |
tree | f748902be5f5448d91867cc317765293e957d562 /source4/dsdb | |
parent | 58aa29b8444776874fc409ec0a063567de8b522e (diff) | |
download | samba-cff0978495da54c019148709a07ccf5f947cf5ec.tar.gz |
s4:dsdb/common: add dsdb_module_werror() helper function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/common/util.c | 11 | ||||
-rw-r--r-- | source4/dsdb/common/util.h | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index b0c89b7f792..dd25987ffc0 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -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 diff --git a/source4/dsdb/common/util.h b/source4/dsdb/common/util.h index dcf3fc44b13..10850736e7d 100644 --- a/source4/dsdb/common/util.h +++ b/source4/dsdb/common/util.h @@ -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__ */ |