return LDB_ERR_SUCCESS;
}
+static void ldb_reset_err_string(struct ldb_context *ldb)
+{
+ if (ldb->err_string) {
+ talloc_free(ldb->err_string);
+ ldb->err_string = NULL;
+ }
+}
+
/*
start a transaction
*/
const char *expression,
const char * const *attrs, struct ldb_message ***res)
{
+ ldb_reset_err_string(ldb);
+
return ldb->modules->ops->search(ldb->modules, base, scope, expression, attrs, res);
}
struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res)
{
+ ldb_reset_err_string(ldb);
+
return ldb->modules->ops->search_bytree(ldb->modules, base, scope, tree, attrs, res);
}
{
int status;
+ ldb_reset_err_string(ldb);
status = ldb_msg_sanity_check(message);
if (status != LDB_ERR_SUCCESS) return status;
{
int status;
+ ldb_reset_err_string(ldb);
+
status = ldb_msg_sanity_check(message);
if (status != LDB_ERR_SUCCESS) return status;
*/
int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
{
- int status = ldb_start_trans(ldb);
+ int status;
+
+ ldb_reset_err_string(ldb);
+
+ status = ldb_start_trans(ldb);
if (status != LDB_ERR_SUCCESS) return status;
status = ldb->modules->ops->delete_record(ldb->modules, dn);
*/
int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
- int status = ldb_start_trans(ldb);
+ int status;
+
+ ldb_reset_err_string(ldb);
+
+ status = ldb_start_trans(ldb);
if (status != LDB_ERR_SUCCESS) return status;
status = ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
*/
const char *ldb_errstring(struct ldb_context *ldb)
{
- if (ldb->modules == NULL) {
- return "ldb not connected";
+ if (ldb->err_string) {
+ return ldb->err_string;
}
- return ldb->modules->ops->errstring(ldb->modules);
+
+ return NULL;
}
return module->next->ops->end_transaction(module->next, status);
}
-const char *ldb_next_errstring(struct ldb_module *module)
+void ldb_set_errstring(struct ldb_module *module, char *err_string)
{
- if (!module->next) {
- return NULL;
+ if (module->ldb->err_string) {
+ talloc_free(module->ldb->err_string);
}
- return module->next->ops->errstring(module->next);
+
+ module->ldb->err_string = err_string;
}
int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *);
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *, int);
- const char * (*errstring)(struct ldb_module *);
};
} *opaque;
struct ldb_schema schema;
+
+ char *err_string;
};
/* the modules init function */
int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
int ldb_next_start_trans(struct ldb_module *module);
int ldb_next_end_trans(struct ldb_module *module, int status);
-const char *ldb_next_errstring(struct ldb_module *module);
+
+void ldb_set_errstring(struct ldb_module *module, char *err_string);
/* The following definitions come from lib/ldb/common/ldb_debug.c */
void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
ildb->last_rc = ildap_rename(ildb->ldap, old_dn, newrdn, parentdn, True);
if (!NT_STATUS_IS_OK(ildb->last_rc)) {
+ ldb_set_errstring(module, talloc_strdup(module, ldap_errstr(ildb->ldap, ildb->last_rc)));
ret = -1;
}
ildb->last_rc = ildap_delete(ildb->ldap, del_dn);
if (!NT_STATUS_IS_OK(ildb->last_rc)) {
+ ldb_set_errstring(module, talloc_strdup(module, ldap_errstr(ildb->ldap, ildb->last_rc)));
ret = -1;
}
ildb->last_rc = ildap_add(ildb->ldap, dn, mods);
if (!NT_STATUS_IS_OK(ildb->last_rc)) {
+ ldb_set_errstring(module, talloc_strdup(module, ldap_errstr(ildb->ldap, ildb->last_rc)));
ret = -1;
}
ildb->last_rc = ildap_modify(ildb->ldap, dn, mods);
if (!NT_STATUS_IS_OK(ildb->last_rc)) {
+ ldb_set_errstring(module, talloc_strdup(module, ldap_errstr(ildb->ldap, ildb->last_rc)));
ret = -1;
}
return status;
}
-/*
- return extended error information
-*/
-static const char *ildb_errstring(struct ldb_module *module)
-{
- struct ildb_private *ildb = talloc_get_type(module->private_data,
- struct ildb_private);
- if (ildb == NULL) {
- return "ildap not connected";
- }
- return ldap_errstr(ildb->ldap, ildb->last_rc);
-}
-
-
static const struct ldb_module_ops ildb_ops = {
.name = "ldap",
.search = ildb_search,
.delete_record = ildb_delete,
.rename_record = ildb_rename,
.start_transaction = ildb_start_trans,
- .end_transaction = ildb_end_trans,
- .errstring = ildb_errstring
+ .end_transaction = ildb_end_trans
};
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;
}
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;
}
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;
}
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;
}
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;
}
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,
.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
};
#include <stdarg.h>
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#include "ldb/ldb_sqlite3/ldb_sqlite3.h"
if (basedn) {
norm_basedn = ldb_dn_linearize(local_ctx, ldb_dn_casefold(module->ldb, basedn));
- if (norm_basedn == NULL) goto failed;
+ if (norm_basedn == NULL) {
+ ret = LDB_ERR_INVALID_DN_SYNTAX;
+ goto failed;
+ }
} else norm_basedn = talloc_strdup(local_ctx, "");
if (*norm_basedn == '\0' &&
- (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL))
+ (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) {
+ ret = LDB_ERR_UNWILLING_TO_PERFORM;
goto failed;
+ }
/* Convert filter into a series of SQL conditions (constraints) */
sqlfilter = parsetree_to_sql(module, local_ctx, tree);
}
if (query == NULL) {
- ret = -1;
+ ret = LDB_ERR_OTHER;
goto failed;
}
ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, &msgs, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_search_bytree: Fatal Error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
for (i = 0; i < msgs.count; i++) {
msgs.msgs[i] = ldb_msg_canonicalize(module->ldb, msgs.msgs[i]);
- if (msgs.msgs[i] == NULL) goto failed;
+ if (msgs.msgs[i] == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
}
*res = talloc_steal(module, msgs.msgs);
/* create a local ctx */
local_ctx = talloc_named(lsqlite3, 0, "lsqlite3_add local context");
if (local_ctx == NULL) {
- return -1;
+ return LDB_ERR_OTHER;
}
/* See if this is an ltdb special */
c = ldb_dn_explode(local_ctx, "@SUBCLASSES");
if (ldb_dn_compare(module->ldb, msg->dn, c) == 0) {
#warning "insert subclasses into object class tree"
+ ret = LDB_ERR_UNWILLING_TO_PERFORM;
goto failed;
}
}
*/
/* Others are implicitly ignored */
- return 0;
+ return LDB_ERR_SUCCESS;
}
/* create linearized and normalized dns */
dn = ldb_dn_linearize(local_ctx, msg->dn);
ndn = ldb_dn_linearize(local_ctx, ldb_dn_casefold(module->ldb, msg->dn));
- if (dn == NULL || ndn == NULL) goto failed;
+ if (dn == NULL || ndn == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
query = lsqlite3_tprintf(local_ctx,
/* Add new entry */
"('dn', 'norm_dn') "
"VALUES ('%q', '%q');",
dn, ndn);
- if (query == NULL) goto failed;
+ if (query == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_add: exec error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, local_ctx, ndn);
- if (eid == -1) goto failed;
+ if (eid == -1) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
for (i = 0; i < msg->num_elements; i++) {
const struct ldb_message_element *el = &msg->elements[i];
/* Get a case-folded copy of the attribute name */
attr = ldb_casefold(local_ctx, el->name);
- if (attr == NULL) goto failed;
+ if (attr == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
h = ldb_attrib_handler(module->ldb, el->name);
/* Get a canonicalised copy of the data */
h->canonicalise_fn(module->ldb, local_ctx, &(el->values[j]), &value);
- if (value.data == NULL) goto failed;
+ if (value.data == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
insert = lsqlite3_tprintf(local_ctx,
"INSERT OR ROLLBACK INTO ldb_attribute_values "
"VALUES ('%lld', '%q', '%q', '%q', '%q');",
eid, el->name, attr,
el->values[j].data, value.data);
- if (insert == NULL) goto failed;
+ if (insert == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_add: insert error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
}
}
talloc_free(local_ctx);
- return 0;
+ return LDB_ERR_SUCCESS;
failed:
talloc_free(local_ctx);
- return -1;
+ return ret;
}
/* create a local ctx */
local_ctx = talloc_named(lsqlite3, 0, "lsqlite3_modify local context");
if (local_ctx == NULL) {
- return -1;
+ return LDB_ERR_OTHER;
}
/* See if this is an ltdb special */
c = ldb_dn_explode(local_ctx, "@SUBCLASSES");
if (ldb_dn_compare(module->ldb, msg->dn, c) == 0) {
#warning "modify subclasses into object class tree"
- goto failed;
- }
-
- c = ldb_dn_explode(local_ctx, "@INDEXLIST");
- if (ldb_dn_compare(module->ldb, msg->dn, c) == 0) {
-#warning "should we handle indexes somehow ?"
+ ret = LDB_ERR_UNWILLING_TO_PERFORM;
goto failed;
}
/* Others are implicitly ignored */
- return 0;
+ return LDB_ERR_SUCCESS;
}
eid = lsqlite3_get_eid(module, msg->dn);
if (eid == -1) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
/* Get a case-folded copy of the attribute name */
attr = ldb_casefold(local_ctx, el->name);
if (attr == NULL) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
"WHERE eid = '%lld' "
"AND norm_attr_name = '%q';",
eid, attr);
- if (mod == NULL) goto failed;
+ if (mod == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_modify: error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
/* Get a canonicalised copy of the data */
h->canonicalise_fn(module->ldb, local_ctx, &(el->values[j]), &value);
if (value.data == NULL) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
eid, el->name, attr,
el->values[j].data, value.data);
- if (mod == NULL) goto failed;
+ if (mod == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_modify: error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
}
"WHERE eid = '%lld' "
"AND norm_attr_name = '%q';",
eid, attr);
- if (mod == NULL) goto failed;
+ if (mod == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_modify: error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
}
/* Get a canonicalised copy of the data */
h->canonicalise_fn(module->ldb, local_ctx, &(el->values[j]), &value);
if (value.data == NULL) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
"AND norm_attr_value = '%q';",
eid, attr, value.data);
- if (mod == NULL) goto failed;
+ if (mod == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_modify: error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
}
}
talloc_free(local_ctx);
- return 0;
+ return LDB_ERR_SUCCESS;
failed:
talloc_free(local_ctx);
- return -1;
+ return ret;
}
/* delete a record */
/* ignore ltdb specials */
if (ldb_dn_is_special(dn)) {
- return 0;
+ return LDB_ERR_SUCCESS;
}
/* create a local ctx */
local_ctx = talloc_named(lsqlite3, 0, "lsqlite3_delete local context");
if (local_ctx == NULL) {
- return -1;
+ return LDB_ERR_OTHER;
}
eid = lsqlite3_get_eid(module, dn);
- if (eid == -1) goto failed;
+ if (eid == -1) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
query = lsqlite3_tprintf(local_ctx,
/* Delete entry */
/* Delete attributes */
"DELETE FROM ldb_attribute_values WHERE eid = %lld; ",
eid, eid);
- if (query == NULL) goto failed;
+ if (query == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_delete: error getting eid: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
talloc_free(local_ctx);
- return 0;
+ return LDB_ERR_SUCCESS;
failed:
talloc_free(local_ctx);
- return -1;
+ return ret;
}
/* rename a record */
/* ignore ltdb specials */
if (ldb_dn_is_special(olddn) || ldb_dn_is_special(newdn)) {
- return 0;
+ return LDB_ERR_SUCCESS;
}
/* create a local ctx */
local_ctx = talloc_named(lsqlite3, 0, "lsqlite3_rename local context");
if (local_ctx == NULL) {
- return -1;
+ return LDB_ERR_OTHER;
}
/* create linearized and normalized dns */
old_cdn = ldb_dn_linearize(local_ctx, ldb_dn_casefold(module->ldb, olddn));
new_cdn = ldb_dn_linearize(local_ctx, ldb_dn_casefold(module->ldb, newdn));
new_dn = ldb_dn_linearize(local_ctx, newdn);
- if (old_cdn == NULL || new_cdn == NULL || new_dn == NULL) goto failed;
+ if (old_cdn == NULL || new_cdn == NULL || new_dn == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
/* build the SQL query */
query = lsqlite3_tprintf(local_ctx,
"UPDATE ldb_entry SET dn = '%q', norm_dn = '%q' "
"WHERE norm_dn = '%q';",
new_dn, new_cdn, old_cdn);
- if (query == NULL) goto failed;
+ if (query == NULL) {
+ ret = LDB_ERR_OTHER;
+ goto failed;
+ }
/* execute */
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- printf("lsqlite3_rename: sqlite3_exec error: %s\n", errmsg);
+ ldb_set_errstring(module, talloc_strdup(module, errmsg));
free(errmsg);
}
+ ret = LDB_ERR_OTHER;
goto failed;
}
/* clean up and exit */
talloc_free(local_ctx);
- return 0;
+ return LDB_ERR_SUCCESS;
failed:
talloc_free(local_ctx);
- return -1;
+ return ret;
}
static int lsqlite3_start_trans(struct ldb_module * module)
char *errmsg;
struct lsqlite3_private * lsqlite3 = module->private_data;
- ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN IMMEDIATE;", NULL, NULL, &errmsg);
- if (ret != SQLITE_OK) {
- if (errmsg) {
- printf("lsqlite3_start_trans: error: %s\n", errmsg);
- free(errmsg);
+ if (lsqlite3->trans_count == 0) {
+ ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN IMMEDIATE;", NULL, NULL, &errmsg);
+ if (ret != SQLITE_OK) {
+ if (errmsg) {
+ printf("lsqlite3_start_trans: error: %s\n", errmsg);
+ free(errmsg);
+ }
+ return -1;
}
- return -1;
- }
+ };
+
+ lsqlite3->trans_count++;
return 0;
}
char *errmsg;
struct lsqlite3_private *lsqlite3 = module->private_data;
- if (status == 0) {
- ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg);
- if (ret != SQLITE_OK) {
- if (errmsg) {
- printf("lsqlite3_end_trans: error: %s\n", errmsg);
- free(errmsg);
+ lsqlite3->trans_count--;
+
+ if (lsqlite3->trans_count == 0) {
+ if (status == 0) {
+ ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg);
+ if (ret != SQLITE_OK) {
+ if (errmsg) {
+ printf("lsqlite3_end_trans: error: %s\n", errmsg);
+ free(errmsg);
+ }
+ return -1;
}
- return -1;
+ } else {
+ return lsqlite3_safe_rollback(lsqlite3->sqlite);
}
- } else {
- return lsqlite3_safe_rollback(lsqlite3->sqlite);
}
return 0;
}
-
-
-/* return extended error information */
-static const char *
-lsqlite3_errstring(struct ldb_module *module)
-{
- struct lsqlite3_private * lsqlite3 = module->private_data;
-
- return sqlite3_errmsg(lsqlite3->sqlite);
-}
-
-
-
-
/*
* Static functions
*/
.delete_record = lsqlite3_delete,
.rename_record = lsqlite3_rename,
.start_transaction = lsqlite3_start_trans,
- .end_transaction = lsqlite3_end_trans,
- .errstring = lsqlite3_errstring
+ .end_transaction = lsqlite3_end_trans
};
/*
lsqlite3->sqlite = NULL;
lsqlite3->options = NULL;
+ lsqlite3->trans_count = 0;
ret = initialize(lsqlite3, ldb, url);
if (ret != SQLITE_OK) {
#include <sqlite3.h>
struct lsqlite3_private {
+ int trans_count;
char **options;
sqlite3 *sqlite;
};
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#include "ldb/ldb_tdb/ldb_tdb.h"
const char * const attrs[], struct ldb_message ***res)
{
struct ldb_context *ldb = module->ldb;
- struct ltdb_private *ltdb = module->private_data;
int ret;
struct ldb_message *msg, *msg2;
return -1;
}
- ltdb->last_err_string = NULL;
-
if (ltdb_cache_load(module) != 0) {
ltdb_unlock_read(module);
return -1;
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const attrs[], struct ldb_message ***res)
{
- struct ltdb_private *ltdb = module->private_data;
int ret;
if ((base == NULL || base->comp_num == 0) &&
struct ldb_dn *dn;
dn = ldb_dn_explode(module->ldb, tree->u.equality.value.data);
if (dn == NULL) {
- return -1;
+ return LDB_ERR_INVALID_DN_SYNTAX;
}
ret = ltdb_search_dn(module, dn, attrs, res);
talloc_free(dn);
return -1;
}
- ltdb->last_err_string = NULL;
-
if (ltdb_cache_load(module) != 0) {
ltdb_unlock_read(module);
return -1;
tree = ldb_parse_tree(ltdb, expression);
if (tree == NULL) {
- ltdb->last_err_string = "expression parse failed";
+ char *err_string = talloc_strdup(module, "expression parse failed");
+ if (err_string) ldb_set_errstring(module, err_string);
return -1;
}
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#include "ldb/ldb_tdb/ldb_tdb.h"
*/
int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
int i, j;
if (! ldb_dn_is_special(msg->dn) ||
for (i = 0; i < msg->num_elements; i++) {
for (j = 0; j < msg->elements[i].num_values; j++) {
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
- ltdb->last_err_string = "Invalid attribute value in an @ATTRIBUTES entry";
- return -1;
+ char *err_string = talloc_strdup(module, "Invalid attribute value in an @ATTRIBUTES entry");
+ if (err_string) {
+ ldb_set_errstring(module, err_string);
+ }
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
}
}
tdb_key = ltdb_key(module, msg->dn);
if (!tdb_key.dptr) {
- return -1;
+ return LDB_ERR_OTHER;
}
ret = ltdb_pack_data(module, msg, &tdb_data);
if (ret == -1) {
talloc_free(tdb_key.dptr);
- return -1;
+ return LDB_ERR_OTHER;
}
ret = tdb_store(ltdb->tdb, tdb_key, tdb_data, flgs);
if (ret == -1) {
+ ret = LDB_ERR_OTHER;
goto done;
}
*/
static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
int ret;
- ltdb->last_err_string = NULL;
-
ret = ltdb_check_special_dn(module, msg);
- if (ret != 0) {
+ if (ret != LDB_ERR_SUCCESS) {
return ret;
}
if (ltdb_lock(module, LDBLOCK) != 0) {
- return -1;
+ return LDB_ERR_OTHER;
}
if (ltdb_cache_load(module) != 0) {
ltdb_unlock(module, LDBLOCK);
- return -1;
+ return LDB_ERR_OTHER;
}
ret = ltdb_store(module, msg, TDB_INSERT);
- if (ret == 0) {
+ if (ret == LDB_ERR_SUCCESS) {
ltdb_modified(module, msg->dn);
}
tdb_key = ltdb_key(module, dn);
if (!tdb_key.dptr) {
- return -1;
+ return LDB_ERR_OTHER;
}
ret = tdb_delete(ltdb->tdb, tdb_key);
talloc_free(tdb_key.dptr);
+ if (ret != 0) ret = LDB_ERR_OTHER;
+
return ret;
}
*/
static int ltdb_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
- struct ltdb_private *ltdb = module->private_data;
- int ret;
struct ldb_message *msg = NULL;
-
- ltdb->last_err_string = NULL;
+ int ret = LDB_ERR_OTHER;
if (ltdb_lock(module, LDBLOCK) != 0) {
- return -1;
+ return ret;
}
if (ltdb_cache_load(module) != 0) {
ret = ltdb_search_dn1(module, dn, msg);
if (ret != 1) {
/* not finding the old record is an error */
+ ret = LDB_ERR_NO_SUCH_OBJECT;
goto failed;
}
ret = ltdb_delete_noindex(module, dn);
- if (ret == -1) {
+ if (ret != LDB_ERR_SUCCESS) {
goto failed;
}
/* remove any indexed attributes */
ret = ltdb_index_del(module, msg);
-
- if (ret == 0) {
+ if (ret == LDB_ERR_SUCCESS) {
ltdb_modified(module, dn);
- }
+ } else
+ ret = LDB_ERR_OTHER;
talloc_free(msg);
ltdb_unlock(module, LDBLOCK);
failed:
talloc_free(msg);
ltdb_unlock(module, LDBLOCK);
- return -1;
+ return ret;
}
tdb_key = ltdb_key(module, msg->dn);
if (!tdb_key.dptr) {
- return -1;
+ return LDB_ERR_OTHER;
}
tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
if (!tdb_data.dptr) {
talloc_free(tdb_key.dptr);
- return -1;
+ return LDB_ERR_OTHER;
}
msg2 = talloc(tdb_key.dptr, struct ldb_message);
if (msg2 == NULL) {
talloc_free(tdb_key.dptr);
- return -1;
+ return LDB_ERR_OTHER;
}
ret = ltdb_unpack_data(module, &tdb_data, msg2);
if (ret == -1) {
talloc_free(tdb_key.dptr);
free(tdb_data.dptr);
- return -1;
+ return LDB_ERR_OTHER;
}
if (!msg2->dn) {
struct ldb_message_element *el = &msg->elements[i];
struct ldb_message_element *el2;
struct ldb_val *vals;
+ char *err_string;
char *dn;
switch (msg->elements[i].flags & LDB_FLAG_MOD_MASK) {
if (ret == -1) {
if (msg_add_element(ldb, msg2, el) != 0) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
continue;
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
- ltdb->last_err_string =
- "Type or value exists";
+ err_string = talloc_strdup(module, "Type or value exists");
+ if (err_string) ldb_set_errstring(module, err_string);
+ ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
}
if (msg->elements[i].num_values == 0) {
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
- ltdb->last_err_string = "No such attribute";
+ err_string = talloc_strdup(module, "No such attribute");
+ if (err_string) ldb_set_errstring(module, err_string);
+ ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
break;
msg2,
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
- ltdb->last_err_string = "No such attribute";
+ err_string = talloc_strdup(module, "No such attribute");
+ if (err_string) ldb_set_errstring(module, err_string);
+ ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
if (ltdb_index_del_value(module, dn, &msg->elements[i], j) != 0) {
}
break;
default:
- ltdb->last_err_string = "Invalid ldb_modify flags";
+ err_string = talloc_strdup(module, "Invalid ldb_modify flags");
+ if (err_string) ldb_set_errstring(module, err_string);
+ ret = LDB_ERR_PROTOCOL_ERROR;
goto failed;
}
}
failed:
talloc_free(tdb_key.dptr);
free(tdb_data.dptr);
- return -1;
+ return ret;
}
/*
*/
static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
int ret;
- ltdb->last_err_string = NULL;
-
ret = ltdb_check_special_dn(module, msg);
if (ret != 0) {
return ret;
ret = ltdb_modify_internal(module, msg);
- if (ret == 0) {
+ if (ret == LDB_ERR_SUCCESS) {
ltdb_modified(module, msg->dn);
}
*/
static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
- struct ltdb_private *ltdb = module->private_data;
- int ret;
struct ldb_message *msg;
- const char *error_str;
-
- ltdb->last_err_string = NULL;
+ char *error_str;
+ int ret = LDB_ERR_OTHER;
if (ltdb_lock(module, LDBLOCK) != 0) {
- return -1;
+ return ret;
}
if (ltdb_cache_load(module) != 0) {
ltdb_unlock(module, LDBLOCK);
- return -1;
+ return ret;
}
msg = talloc(module, struct ldb_message);
ret = ltdb_search_dn1(module, olddn, msg);
if (ret != 1) {
/* not finding the old record is an error */
+ ret = LDB_ERR_NO_SUCH_OBJECT;
goto failed;
}
msg->dn = ldb_dn_copy(msg, newdn);
if (!msg->dn) {
+ ret = LDB_ERR_OTHER;
goto failed;
}
ret = ltdb_add(module, msg);
- if (ret == -1) {
+ if (ret != LDB_ERR_SUCCESS) {
goto failed;
}
ret = ltdb_delete(module, olddn);
- error_str = ltdb->last_err_string;
- if (ret == -1) {
+ error_str = talloc_strdup(module, ldb_errstring(module->ldb));
+ if (ret != LDB_ERR_SUCCESS) {
ltdb_delete(module, newdn);
}
- ltdb->last_err_string = error_str;
+ ldb_set_errstring(module, error_str);
talloc_free(msg);
ltdb_unlock(module, LDBLOCK);
failed:
talloc_free(msg);
ltdb_unlock(module, LDBLOCK);
- return -1;
+ return ret;
}
static int ltdb_start_trans(struct ldb_module *module)
{
/* TODO: implement transactions */
- return 0;
+ return LDB_ERR_SUCCESS;
}
static int ltdb_end_trans(struct ldb_module *module, int status)
return status;
}
-/*
- return extended error information
-*/
-static const char *ltdb_errstring(struct ldb_module *module)
-{
- struct ltdb_private *ltdb = module->private_data;
- if (ltdb->last_err_string) {
- return ltdb->last_err_string;
- }
- return tdb_errorstr(ltdb->tdb);
-}
-
-
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
.search = ltdb_search,
.delete_record = ltdb_delete,
.rename_record = ltdb_rename,
.start_transaction = ltdb_start_trans,
- .end_transaction = ltdb_end_trans,
- .errstring = ltdb_errstring
+ .end_transaction = ltdb_end_trans
};
int flags;
} last_attribute;
} *cache;
-
- /* error if an internal ldb+tdb error */
- const char *last_err_string;
};
/* special record types */
struct map_private {
struct ldb_map_context context;
- const char *last_err_string;
};
static struct ldb_map_context *map_get_privdat(struct ldb_module *module)
talloc_free(newattrs);
if (mpret == -1) {
- struct map_private *map_private = module->private_data;
- map_private->last_err_string = ldb_errstring(privdat->mapped_ldb);
+ ldb_set_errstring(module, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
return -1;
}
enum ldb_scope scope, const char *expression,
const char * const *attrs, struct ldb_message ***res)
{
- struct map_private *map = module->private_data;
struct ldb_parse_tree *tree;
int ret;
tree = ldb_parse_tree(NULL, expression);
if (tree == NULL) {
- map->last_err_string = "expression parse failed";
+ ldb_set_errstring(module, talloc_strdup(module, "expression parse failed"));
return -1;
}
ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
ret = ldb_next_add_record(module, fb);
if (ret == -1) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Adding fallback record failed: %s", ldb_next_errstring(module));
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Adding fallback record failed: %s", ldb_errstring(module->ldb));
return -1;
}
return ldb_next_end_trans(module, status);
}
-/*
- return extended error information
-*/
-static const char *map_errstring(struct ldb_module *module)
-{
- struct map_private *map = module->private_data;
-
- if (map->last_err_string)
- return map->last_err_string;
-
- return ldb_next_errstring(module);
-}
-
static const struct ldb_module_ops map_ops = {
.name = "map",
.search = map_search,
.delete_record = map_delete,
.rename_record = map_rename,
.start_transaction = map_start_trans,
- .end_transaction = map_end_trans,
- .errstring = map_errstring
+ .end_transaction = map_end_trans
};
static char *map_find_url(struct ldb_context *ldb, const char *name)
talloc_free(url);
- data->last_err_string = NULL;
-
/* Get list of attribute maps */
j = 0;
data->context.attribute_maps = NULL;
#include "ldb/include/ldb_private.h"
#include <time.h>
-struct private_data {
- const char *error_string;
-};
-
static int rdn_name_search(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, const char *expression,
const char * const *attrs, struct ldb_message ***res)
/* add_record: add crateTimestamp/modifyTimestamp attributes */
static int rdn_name_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
- struct private_data *data = (struct private_data *)module->private_data;
-
struct ldb_message *msg2;
struct ldb_message_element *attribute;
struct ldb_dn_component *rdn;
}
}
if (i == attribute->num_values) {
- data->error_string = talloc_asprintf(data, "RDN mismatch on %s: %s", ldb_dn_linearize(msg2, msg2->dn), rdn->name);
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "%s\n", data->error_string);
+ char *error_string = talloc_asprintf(module, "RDN mismatch on %s: %s", ldb_dn_linearize(msg2, msg2->dn), rdn->name);
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_FATAL, "%s\n", error_string);
+ }
talloc_free(msg2);
return -1;
}
return ldb_next_end_trans(module, status);
}
-/* return extended error information */
-static const char *rdn_name_errstring(struct ldb_module *module)
-{
- struct private_data *data = (struct private_data *)module->private_data;
-
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_errstring\n");
- if (data->error_string) {
- const char *error;
-
- error = data->error_string;
- data->error_string = NULL;
- return error;
- }
-
- return ldb_next_errstring(module);
-}
-
static int rdn_name_destructor(void *module_ctx)
{
/* struct ldb_module *ctx = module_ctx; */
.delete_record = rdn_name_delete_record,
.rename_record = rdn_name_rename_record,
.start_transaction = rdn_start_trans,
- .end_transaction = rdn_end_trans,
- .errstring = rdn_name_errstring
+ .end_transaction = rdn_end_trans
};
#endif
{
struct ldb_module *ctx;
- struct private_data *data;
ctx = talloc(ldb, struct ldb_module);
if (!ctx)
return NULL;
- data = talloc(ctx, struct private_data);
- if (!data) {
- talloc_free(ctx);
- return NULL;
- }
-
- data->error_string = NULL;
- ctx->private_data = data;
+ ctx->private_data = NULL;
ctx->ldb = ldb;
ctx->prev = ctx->next = NULL;
ctx->ops = &rdn_name_ops;
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#define SCHEMA_FLAG_RESET 0
check there's only one structrual class (or a chain of structural classes)
*/
-struct private_data {
- const char *error_string;
-};
-
struct schema_attribute {
int flags;
char *name;
recursively get parent objectlasses attributes */
static int get_attr_list_recursive(struct ldb_module *module, struct schema_structures *schema_struct)
{
- struct private_data *data = (struct private_data *)module->private_data;
struct ldb_message **srch;
+ char *error_string;
int i, j;
int ret;
if (ret <= 0) {
/* Schema DB Error: Error occurred retrieving Object Class Description */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Error retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- data->error_string = "Internal error. Error retrieving schema objectclass";
+ error_string = talloc_asprintf(module, "Error retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
return -1;
}
if (ret > 1) {
/* Schema DB Error: Too Many Records */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Too many records found retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- data->error_string = "Internal error. Too many records searching for schema objectclass";
+ error_string = talloc_asprintf(module, "Too many records found retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
return -1;
}
/* add_record */
static int schema_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
- struct private_data *data = (struct private_data *)module->private_data;
struct schema_structures *entry_structs;
+ char *error_string;
unsigned int i;
int ret;
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ error_string = talloc_asprintf(module,
"The required_attrs attribute %s is missing.\n",
entry_structs->required_attrs.attr[i].name);
-
- data->error_string = "Objectclass violation, a required attribute is missing";
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
talloc_free(entry_structs);
- return -1;
+ return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
/* mark the attribute as checked */
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ error_string = talloc_asprintf(module,
"The attribute %s is not referenced by any objectclass.\n",
entry_structs->entry_attrs.attr[i].name);
-
- data->error_string = "Objectclass violation, an invalid attribute name was found";
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
talloc_free(entry_structs);
- return -1;
+ return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
}
}
/* modify_record */
static int schema_modify_record(struct ldb_module *module, const struct ldb_message *msg)
{
- struct private_data *data = (struct private_data *)module->private_data;
struct schema_structures *entry_structs;
+ char *error_string;
unsigned int i;
int ret;
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ error_string = talloc_asprintf(module,
"The required_attrs attribute %s is missing.\n",
entry_structs->required_attrs.attr[i].name);
-
- data->error_string = "Objectclass violation, a required attribute is missing";
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
talloc_free(entry_structs);
- return -1;
+ return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
/* check we are not trying to delete a required attribute */
/* TODO: consider multivalued attrs */
if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ error_string = talloc_asprintf(module,
"Trying to delete the required attribute %s.\n",
attr->name);
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
- data->error_string = "Objectclass violation, a required attribute cannot be removed";
talloc_free(entry_structs);
- return -1;
+ return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
/* mark the attribute as checked */
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ error_string = talloc_asprintf(module,
"The attribute %s is not referenced by any objectclass.\n",
entry_structs->entry_attrs.attr[i].name);
+ if (error_string) {
+ ldb_set_errstring(module, error_string);
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
+ }
- data->error_string = "Objectclass violation, an invalid attribute name was found";
talloc_free(entry_structs);
- return -1;
+ return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
}
}
return ldb_next_end_trans(module, status);
}
-/* return extended error information */
-static const char *schema_errstring(struct ldb_module *module)
-{
- struct private_data *data = (struct private_data *)module->private_data;
-
- if (data->error_string) {
- const char *error;
-
- error = data->error_string;
- data->error_string = NULL;
- return error;
- }
-
- return ldb_next_errstring(module);
-}
-
static int schema_destructor(void *module_ctx)
{
/* struct ldb_module *ctx = module_ctx; */
.delete_record = schema_delete_record,
.rename_record = schema_rename_record,
.start_transaction = schema_start_trans,
- .end_transaction = schema_end_trans,
- .errstring = schema_errstring,
+ .end_transaction = schema_end_trans
};
#ifdef HAVE_DLOPEN_DISABLED
#endif
{
struct ldb_module *ctx;
- struct private_data *data;
ctx = talloc(ldb, struct ldb_module);
if (!ctx) {
return NULL;
}
- data = talloc(ctx, struct private_data);
- if (data == NULL) {
- talloc_free(ctx);
- return NULL;
- }
-
- data->error_string = NULL;
- ctx->private_data = data;
+ ctx->private_data = NULL;
ctx->ldb = ldb;
ctx->prev = ctx->next = NULL;
ctx->ops = &schema_ops;
struct private_data {
- char *errstring;
+ char *some_private_data;
};
/* search */
return ldb_next_end_trans(module, status);
}
-/* return extended error information */
-static const char *skel_errstring(struct ldb_module *module)
-{
- return ldb_next_errstring(module);
-}
-
static int skel_destructor(void *module_ctx)
{
struct ldb_module *ctx = talloc_get_type(module_ctx, struct ldb_module);
struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
/* put your clean-up functions here */
- if (data->errstring) talloc_free(data->errstring);
+ if (data->some_private_data) talloc_free(data->some_private_data);
return 0;
}
.rename_record = skel_rename_record,
.start_transaction = skel_start_trans,
.end_transaction = skel_end_trans,
- .errstring = skel_errstring
};
#ifdef HAVE_DLOPEN_DISABLED
return NULL;
}
- data->errstring = NULL;
+ data->some_private_data = NULL;
ctx->private_data = data;
ctx->ldb = ldb;
#include "ldb/include/ldb_private.h"
#include <time.h>
-struct private_data {
- const char *error_string;
-};
-
static int timestamps_search(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, const char *expression,
const char * const *attrs, struct ldb_message ***res)
return ldb_next_end_trans(module, status);
}
-/* return extended error information */
-static const char *timestamps_errstring(struct ldb_module *module)
-{
- struct private_data *data = (struct private_data *)module->private_data;
-
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_errstring\n");
- if (data->error_string) {
- const char *error;
-
- error = data->error_string;
- data->error_string = NULL;
- return error;
- }
-
- return ldb_next_errstring(module);
-}
-
static int timestamps_destructor(void *module_ctx)
{
/* struct ldb_module *ctx = module_ctx; */
.delete_record = timestamps_delete_record,
.rename_record = timestamps_rename_record,
.start_transaction = timestamps_start_trans,
- .end_transaction = timestamps_end_trans,
- .errstring = timestamps_errstring
+ .end_transaction = timestamps_end_trans
};
#endif
{
struct ldb_module *ctx;
- struct private_data *data;
ctx = talloc(ldb, struct ldb_module);
if (!ctx)
return NULL;
- data = talloc(ctx, struct private_data);
- if (!data) {
- talloc_free(ctx);
- return NULL;
- }
-
- data->error_string = NULL;
- ctx->private_data = data;
+ ctx->private_data = NULL;
ctx->ldb = ldb;
ctx->prev = ctx->next = NULL;
ctx->ops = ×tamps_ops;
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#include "ldb/tools/cmdline.h"
ldif->msg = ldb_msg_canonicalize(ldb, ldif->msg);
ret = ldb_add(ldb, ldif->msg);
- if (ret != 0) {
+ if (ret != LDB_ERR_SUCCESS) {
fprintf(stderr, "ERR: \"%s\" on DN %s\n",
ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
failures++;