From 16aff2a184f7fab64d718b356056070e305e99e9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 18:49:06 +0000 Subject: r10305: start implementing better error handling changed the prioivate modules API error string are now not spread over all modules but are kept in a single place. This allows a better control of memory and error reporting. (This used to be commit 3fc676ac1d6f59d08bedbbd9377986154cf84ce4) --- source4/lib/ldb/ldb_ldap/ldb_ldap.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'source4/lib/ldb/ldb_ldap/ldb_ldap.c') diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 39f56dba0e..2035913f2a 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -78,6 +78,7 @@ static int lldb_rename(struct ldb_module *module, const struct ldb_dn *olddn, co lldb->last_rc = ldap_rename_s(lldb->ldap, old_dn, newrdn, parentdn, 1, NULL, NULL); if (lldb->last_rc != LDAP_SUCCESS) { + ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc))); ret = -1; } @@ -107,6 +108,7 @@ static int lldb_delete(struct ldb_module *module, const struct ldb_dn *edn) lldb->last_rc = ldap_delete_s(lldb->ldap, dn); if (lldb->last_rc != LDAP_SUCCESS) { + ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc))); ret = -1; } @@ -200,6 +202,7 @@ static int lldb_search(struct ldb_module *module, const struct ldb_dn *base, 0, &ldapres); talloc_free(search_base); if (lldb->last_rc != LDAP_SUCCESS) { + ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc))); return -1; } @@ -404,6 +407,7 @@ static int lldb_add(struct ldb_module *module, const struct ldb_message *msg) lldb->last_rc = ldap_add_s(lldb->ldap, dn, mods); if (lldb->last_rc != LDAP_SUCCESS) { + ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc))); ret = -1; } @@ -442,6 +446,7 @@ static int lldb_modify(struct ldb_module *module, const struct ldb_message *msg) lldb->last_rc = ldap_modify_s(lldb->ldap, dn, mods); if (lldb->last_rc != LDAP_SUCCESS) { + ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc))); ret = -1; } @@ -464,16 +469,6 @@ static int lldb_end_trans(struct ldb_module *module, int status) return status; } -/* - return extended error information -*/ -static const char *lldb_errstring(struct ldb_module *module) -{ - struct lldb_private *lldb = module->private_data; - return ldap_err2string(lldb->last_rc); -} - - static const struct ldb_module_ops lldb_ops = { .name = "ldap", .search = lldb_search, @@ -483,8 +478,7 @@ static const struct ldb_module_ops lldb_ops = { .delete_record = lldb_delete, .rename_record = lldb_rename, .start_transaction = lldb_start_trans, - .end_transaction = lldb_end_trans, - .errstring = lldb_errstring + .end_transaction = lldb_end_trans }; -- cgit